remove duplicate single folder size counting

This commit is contained in:
Evan Su 2025-04-17 23:46:04 -04:00
parent 75c0a017f9
commit ee2abd053c

View file

@ -803,6 +803,7 @@ func draw() {
if recombine { if recombine {
multiplier++ multiplier++
} }
fmt.Println(multiplier, requiredFreeSpace)
giu.Style().SetColor(giu.StyleColorText, WHITE).To( giu.Style().SetColor(giu.StyleColorText, WHITE).To(
giu.Label("Ready (ensure " + sizeify(requiredFreeSpace*int64(multiplier)) + " of disk space is free)"), giu.Label("Ready (ensure " + sizeify(requiredFreeSpace*int64(multiplier)) + " of disk space is free)"),
).Build() ).Build()
@ -887,11 +888,6 @@ func onDrop(names []string) {
onlyFolders = append(onlyFolders, names[0]) onlyFolders = append(onlyFolders, names[0])
inputFile = filepath.Join(filepath.Dir(names[0]), "encrypted-"+strconv.Itoa(int(time.Now().Unix()))) + ".zip" inputFile = filepath.Join(filepath.Dir(names[0]), "encrypted-"+strconv.Itoa(int(time.Now().Unix()))) + ".zip"
outputFile = inputFile + ".pcv" outputFile = inputFile + ".pcv"
size, err := dirSize(names[0])
if err != nil {
panic(err)
}
requiredFreeSpace = size
} else { // A file was dropped } else { // A file was dropped
files++ files++
requiredFreeSpace = stat.Size() requiredFreeSpace = stat.Size()
@ -2571,20 +2567,6 @@ func unpackArchive(zipPath string) error {
return nil return nil
} }
func dirSize(path string) (int64, error) {
var size int64
err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
size += info.Size()
}
return err
})
return size, err
}
func main() { func main() {
// Create the main window // Create the main window
window = giu.NewMasterWindow("Picocrypt "+version[1:], 318, 507, giu.MasterWindowFlagsNotResizable) window = giu.NewMasterWindow("Picocrypt "+version[1:], 318, 507, giu.MasterWindowFlagsNotResizable)