1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2025-03-31 01:24:31 +00:00

allways delete tmpFolder when copyDstSubProcFunc is done.

This commit is contained in:
postmannen 2022-12-14 05:48:44 +01:00
parent 33df0df948
commit 2c1ed934dd

View file

@ -657,6 +657,14 @@ func copyDstSubProcFunc(proc process, cia copyInitialData, message Message, canc
return er
}
defer func() {
err = os.RemoveAll(tmpFolder)
if err != nil {
er := fmt.Errorf("error: copyDstSubProcFunc: remove temp dir failed: %v", err)
proc.errorKernel.errSend(proc, message, er)
}
}()
for {
select {
case <-ctx.Done():
@ -878,13 +886,11 @@ func copyDstSubProcFunc(proc process, cia copyInitialData, message Message, canc
proc.errorKernel.errSend(proc, message, er)
}
// Remove the backup file, and tmp folder.
os.Remove(backupOriginalFileName)
err = os.RemoveAll(tmpFolder)
// Remove the backup file.
err = os.Remove(backupOriginalFileName)
if err != nil {
er := fmt.Errorf("error: copyDstSubProcFunc: remove temp dir failed: %v", err)
er := fmt.Errorf("error: copyDstSubProcFunc: remove of backup of original file failed: %v", err)
proc.errorKernel.errSend(proc, message, er)
return er
}
er = fmt.Errorf("info: copy: successfully wrote all split chunk files into file=%v", filePath)