write scan to unique filename each time
This commit is contained in:
parent
9e0474a68f
commit
8a230bdc64
11
main.go
11
main.go
@ -2,8 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
"flag"
|
||||
@ -100,8 +102,15 @@ func (driver *ForwarderDriver) GetFile(path string, offset int64) (int64, io.Rea
|
||||
func (driver *ForwarderDriver) PutFile(destPath string, data io.Reader, appendData bool) (int64, error) {
|
||||
log.Printf("Receiving file %v", destPath)
|
||||
|
||||
dest_filename := path.Base(destPath)
|
||||
|
||||
t := time.Now()
|
||||
encrypted_filename := fmt.Sprintf("scan_%04d-%02d-%02d-%02d-%02d_%v.asc", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), dest_filename)
|
||||
|
||||
log.Printf("Writing to %v", encrypted_filename)
|
||||
|
||||
log.Printf("Opening output file")
|
||||
encryptedFile, err := os.Create("file.pdf.asc")
|
||||
encryptedFile, err := os.Create(encrypted_filename)
|
||||
if err != nil {
|
||||
log.Printf("Error: %v", err)
|
||||
return 0, err
|
||||
|
Loading…
Reference in New Issue
Block a user