Handle all files of set being insider or outside the deleteDupesIn-Folder

This commit is contained in:
Jan Bader 2020-11-22 16:34:36 +01:00
parent 66a9ae73e5
commit 3c3f1d747b

25
main.go
View File

@ -40,6 +40,7 @@ func main() {
if *verbose {
printConfiguration()
}
countFiles := 0
filesMap := newFilesMap()
if *fromFile != "" {
@ -80,6 +81,28 @@ func main() {
continue
}
hasDupesInFolder := false
hasDupesOutsideFolder := false
for _, file := range duplicateFiles {
fileIsInFolder := strings.HasPrefix(filepath.Clean(file), deleteIn)
hasDupesOutsideFolder = hasDupesOutsideFolder || !fileIsInFolder
hasDupesInFolder = hasDupesInFolder || fileIsInFolder
}
if !hasDupesInFolder || !hasDupesOutsideFolder {
if !hasDupesOutsideFolder {
fmt.Println("Not deleting one of the following files, since all would be deleted")
}
if !hasDupesInFolder {
fmt.Println("Not deleting one of the following files, since none are in the selected directory")
}
for _, file := range duplicateFiles {
fmt.Println("-", file)
}
fmt.Println()
continue
}
for _, file := range duplicateFiles {
if strings.HasPrefix(filepath.Clean(file), deleteIn) {
fmt.Println("Would delete ", file)
@ -124,11 +147,9 @@ func main() {
if *force {
remove(file)
}
}
}
} else {
countInstances := 0
countDupeSets := 0
for hash := range filesMap.FilesByHash {