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