diff --git a/main.go b/main.go index 9fb3e64..c0e7cdb 100644 --- a/main.go +++ b/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