fix(save): remove folder before copy (avoid unwanted files)

This commit is contained in:
DataHearth 2022-06-14 12:15:24 +02:00
parent 56da676e15
commit ea25075c82
No known key found for this signature in database
GPG Key ID: E88FD356ACC5F3C4
1 changed files with 5 additions and 0 deletions

View File

@ -116,6 +116,11 @@ func (e *Items) saveItem(src, dst string, index int) string {
dstPerms = s.Mode()
}
// remove the destination if it exists. It cleans up the saved location from unused files
if err := os.RemoveAll(dst); err != nil {
PrintError("[%d] failed to truncate destination folder \"%s\": %v", index, dst, err)
}
if err := os.Mkdir(dst, dstPerms); err != nil {
if !os.IsExist(err) {
PrintError("[%d] failed to create destination folder \"%s\": %v", index, dst, err)