1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

removing tmp files when done

This commit is contained in:
postmannen 2022-06-15 20:12:48 +02:00
parent 97ef587a0e
commit e010a1633a

View file

@ -385,7 +385,7 @@ func copySrcSubProcFunc(proc process, cia copyInitialData) func(context.Context,
chunkNumber++ chunkNumber++
// Create message and send data to dst // Create message and send data to dst
fmt.Printf("**** DATA READ: %v\n", b) // fmt.Printf("**** DATA READ: %v\n", b)
csa := copySubData{ csa := copySubData{
CopyStatus: status, CopyStatus: status,
@ -555,7 +555,7 @@ func copyDstSubProcFunc(proc process, cia copyInitialData, message Message) func
switch csa.CopyStatus { switch csa.CopyStatus {
case copyData: case copyData:
// Write the data chunk to disk ? // Write the data chunk to disk ?
fmt.Printf("\n * Received data: %s\n\n", csa.CopyData) // fmt.Printf("\n * Received data: %s\n\n", csa.CopyData)
func() { func() {
filePath := filepath.Join(tmpFolder, strconv.Itoa(csa.ChunkNumber)+"."+cia.UUID) filePath := filepath.Join(tmpFolder, strconv.Itoa(csa.ChunkNumber)+"."+cia.UUID)
@ -690,8 +690,12 @@ func copyDstSubProcFunc(proc process, cia copyInitialData, message Message) func
return return
} }
// All ok, remove the backup file // All ok, remove the backup file, and tmp folder.
os.Remove(backupOriginalFileName) os.Remove(backupOriginalFileName)
err = os.RemoveAll(tmpFolder)
if err != nil {
log.Fatalf("error: copyDstSubProcFunc: remove temp dir failed: %v\n", err)
}
// fmt.Printf("main file contains: %v\n", mainFileData) // fmt.Printf("main file contains: %v\n", mainFileData)
}() }()