From e010a1633af53d58d573fa9452ce93d95115ad33 Mon Sep 17 00:00:00 2001 From: postmannen Date: Wed, 15 Jun 2022 20:12:48 +0200 Subject: [PATCH] removing tmp files when done --- requests_copy.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/requests_copy.go b/requests_copy.go index 0aff1ae..1777b24 100644 --- a/requests_copy.go +++ b/requests_copy.go @@ -385,7 +385,7 @@ func copySrcSubProcFunc(proc process, cia copyInitialData) func(context.Context, chunkNumber++ // Create message and send data to dst - fmt.Printf("**** DATA READ: %v\n", b) + // fmt.Printf("**** DATA READ: %v\n", b) csa := copySubData{ CopyStatus: status, @@ -555,7 +555,7 @@ func copyDstSubProcFunc(proc process, cia copyInitialData, message Message) func switch csa.CopyStatus { case copyData: // 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() { filePath := filepath.Join(tmpFolder, strconv.Itoa(csa.ChunkNumber)+"."+cia.UUID) @@ -690,8 +690,12 @@ func copyDstSubProcFunc(proc process, cia copyInitialData, message Message) func return } - // All ok, remove the backup file + // All ok, remove the backup file, and tmp folder. 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) }()