Reenable commented logic

This commit is contained in:
Jan Bader 2023-12-06 16:51:05 +01:00
parent f8564f20ac
commit 587f904ebc

28
main.go
View File

@ -1,12 +1,18 @@
package main package main
import ( import (
"bufio"
"encoding/json"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"log" "log"
"os" "os"
"path/filepath"
"runtime" "runtime"
"runtime/pprof" "runtime/pprof"
"strconv"
"strings"
"sync" "sync"
"slices" "slices"
@ -45,11 +51,11 @@ func main() {
var countFiles int64 = 0 var countFiles int64 = 0
filesMap := newFilesMap() filesMap := newFilesMap()
if *fromFile != "" { if *fromFile != "" {
// byteValue, _ := ioutil.ReadFile(*fromFile) byteValue, _ := ioutil.ReadFile(*fromFile)
// err := json.Unmarshal(byteValue, &filesMap.FilesByHash) err := json.Unmarshal(byteValue, &filesMap.FilesByHash)
// if err != nil { if err != nil {
// panic(err) panic(err)
// } }
} else { } else {
filesMap.incomingBar = filesMap.progress.AddSpinner(0, filesMap.incomingBar = filesMap.progress.AddSpinner(0,
mpb.PrependDecorators( mpb.PrependDecorators(
@ -103,12 +109,12 @@ func main() {
} }
if *toFile != "" && *fromFile == "" { if *toFile != "" && *fromFile == "" {
// json, _ := json.MarshalIndent(filesMap.FilesByHash, "", " ") json, _ := json.MarshalIndent(filesMap.FilesByHash, "", " ")
// ioutil.WriteFile(*toFile, json, 0644) ioutil.WriteFile(*toFile, json, 0644)
} }
if *deleteDupesIn != "" { if *deleteDupesIn != "" {
/* deleteIn := filepath.Clean(*deleteDupesIn) deleteIn := filepath.Clean(*deleteDupesIn)
for hash := range filesMap.FilesByHash { for hash := range filesMap.FilesByHash {
duplicateFiles := filesMap.FilesByHash[hash] duplicateFiles := filesMap.FilesByHash[hash]
if len(duplicateFiles) <= 1 { if len(duplicateFiles) <= 1 {
@ -146,9 +152,9 @@ func main() {
} }
} }
} }
}*/ }
} else if *promptForDelete { } else if *promptForDelete {
/* reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
for hash := range filesMap.FilesByHash { for hash := range filesMap.FilesByHash {
duplicateFiles := filesMap.FilesByHash[hash] duplicateFiles := filesMap.FilesByHash[hash]
if len(duplicateFiles) <= 1 { if len(duplicateFiles) <= 1 {
@ -183,7 +189,7 @@ func main() {
remove(file) remove(file)
} }
} }
}*/ }
} else { } else {
countInstances := 0 countInstances := 0
countDupeSets := 0 countDupeSets := 0