mirror of
https://github.com/Picocrypt/Picocrypt.git
synced 2025-05-12 05:48:30 +02:00
Much more reliable free space estimator
This commit is contained in:
parent
9b2b69e442
commit
75c0a017f9
1 changed files with 26 additions and 8 deletions
|
@ -790,8 +790,21 @@ func draw() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if requiredFreeSpace > 0 {
|
if requiredFreeSpace > 0 {
|
||||||
|
multiplier := 1
|
||||||
|
if len(allFiles) > 1 || len(onlyFolders) > 0 { // need a temporary zip file
|
||||||
|
multiplier++
|
||||||
|
}
|
||||||
|
if deniability {
|
||||||
|
multiplier++
|
||||||
|
}
|
||||||
|
if split {
|
||||||
|
multiplier++
|
||||||
|
}
|
||||||
|
if recombine {
|
||||||
|
multiplier++
|
||||||
|
}
|
||||||
giu.Style().SetColor(giu.StyleColorText, WHITE).To(
|
giu.Style().SetColor(giu.StyleColorText, WHITE).To(
|
||||||
giu.Label("Ready (ensure " + sizeify(requiredFreeSpace) + " of disk space is free)"),
|
giu.Label("Ready (ensure " + sizeify(requiredFreeSpace*int64(multiplier)) + " of disk space is free)"),
|
||||||
).Build()
|
).Build()
|
||||||
} else {
|
} else {
|
||||||
giu.Style().SetColor(giu.StyleColorText, WHITE).To(
|
giu.Style().SetColor(giu.StyleColorText, WHITE).To(
|
||||||
|
@ -858,7 +871,12 @@ func onDrop(names []string) {
|
||||||
|
|
||||||
// One item dropped
|
// One item dropped
|
||||||
if len(names) == 1 {
|
if len(names) == 1 {
|
||||||
stat, _ := os.Stat(names[0])
|
stat, err := os.Stat(names[0])
|
||||||
|
if err != nil {
|
||||||
|
mainStatus = "Failed to stat dropped item"
|
||||||
|
mainStatusColor = RED
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// A folder was dropped
|
// A folder was dropped
|
||||||
if stat.IsDir() {
|
if stat.IsDir() {
|
||||||
|
@ -873,10 +891,10 @@ func onDrop(names []string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
requiredFreeSpace = 2 * size
|
requiredFreeSpace = size
|
||||||
} else { // A file was dropped
|
} else { // A file was dropped
|
||||||
files++
|
files++
|
||||||
requiredFreeSpace += stat.Size()
|
requiredFreeSpace = stat.Size()
|
||||||
|
|
||||||
// Is the file a part of a split volume?
|
// Is the file a part of a split volume?
|
||||||
nums := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
|
nums := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
|
||||||
|
@ -913,8 +931,8 @@ func onDrop(names []string) {
|
||||||
}
|
}
|
||||||
totalFiles++
|
totalFiles++
|
||||||
compressTotal += stat.Size()
|
compressTotal += stat.Size()
|
||||||
requiredFreeSpace += stat.Size()
|
|
||||||
}
|
}
|
||||||
|
requiredFreeSpace = compressTotal
|
||||||
} else {
|
} else {
|
||||||
outputFile = names[0][:len(names[0])-4]
|
outputFile = names[0][:len(names[0])-4]
|
||||||
}
|
}
|
||||||
|
@ -1017,7 +1035,7 @@ func onDrop(names []string) {
|
||||||
allFiles = append(allFiles, name)
|
allFiles = append(allFiles, name)
|
||||||
|
|
||||||
compressTotal += stat.Size()
|
compressTotal += stat.Size()
|
||||||
requiredFreeSpace += 2 * stat.Size()
|
requiredFreeSpace += stat.Size()
|
||||||
inputLabel = fmt.Sprintf("Scanning files... (%s)", sizeify(compressTotal))
|
inputLabel = fmt.Sprintf("Scanning files... (%s)", sizeify(compressTotal))
|
||||||
giu.Update()
|
giu.Update()
|
||||||
}
|
}
|
||||||
|
@ -1056,7 +1074,7 @@ func onDrop(names []string) {
|
||||||
if err == nil && !stat.IsDir() {
|
if err == nil && !stat.IsDir() {
|
||||||
allFiles = append(allFiles, path)
|
allFiles = append(allFiles, path)
|
||||||
compressTotal += stat.Size()
|
compressTotal += stat.Size()
|
||||||
requiredFreeSpace += 2 * stat.Size()
|
requiredFreeSpace += stat.Size()
|
||||||
inputLabel = fmt.Sprintf("Scanning files... (%s)", sizeify(compressTotal))
|
inputLabel = fmt.Sprintf("Scanning files... (%s)", sizeify(compressTotal))
|
||||||
giu.Update()
|
giu.Update()
|
||||||
}
|
}
|
||||||
|
@ -1101,7 +1119,7 @@ func work() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Combine/compress all files into a .zip file if needed
|
// Combine/compress all files into a .zip file if needed
|
||||||
if len(allFiles) > 1 || len(onlyFolders) > 0 || compress {
|
if len(allFiles) > 1 || len(onlyFolders) > 0 {
|
||||||
// Consider case where compressing only one file
|
// Consider case where compressing only one file
|
||||||
files := allFiles
|
files := allFiles
|
||||||
if len(allFiles) == 0 {
|
if len(allFiles) == 0 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue