mirror of
https://github.com/Picocrypt/Picocrypt.git
synced 2025-06-28 06:06:13 +02:00
final auto unzip code tweaks
This commit is contained in:
parent
bf73698c52
commit
a929eb1037
1 changed files with 10 additions and 3 deletions
|
@ -2387,17 +2387,25 @@ func unpackArchive(zipPath string) error {
|
||||||
var done int64
|
var done int64
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
for i, f := range reader.File {
|
for _, f := range reader.File {
|
||||||
outPath := filepath.Join(extractDir, f.Name)
|
outPath := filepath.Join(extractDir, filepath.Clean(strings.ReplaceAll(f.Name, "\\", "/")))
|
||||||
|
|
||||||
// Make directory if current entry is a folder
|
// Make directory if current entry is a folder
|
||||||
if f.FileInfo().IsDir() {
|
if f.FileInfo().IsDir() {
|
||||||
if err := os.MkdirAll(outPath, f.Mode()); err != nil {
|
if err := os.MkdirAll(outPath, f.Mode()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, f := range reader.File {
|
||||||
|
// Already handled above
|
||||||
|
if f.FileInfo().IsDir() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
outPath := filepath.Join(extractDir, filepath.Clean(strings.ReplaceAll(f.Name, "\\", "/")))
|
||||||
|
|
||||||
// Otherwise create necessary parent directories
|
// Otherwise create necessary parent directories
|
||||||
if err := os.MkdirAll(filepath.Dir(outPath), 0755); err != nil {
|
if err := os.MkdirAll(filepath.Dir(outPath), 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -2426,7 +2434,6 @@ func unpackArchive(zipPath string) error {
|
||||||
return writeErr
|
return writeErr
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update "done" and recalc progress, speed, eta
|
|
||||||
done += int64(n)
|
done += int64(n)
|
||||||
progress, speed, eta = statify(done, totalSize, startTime)
|
progress, speed, eta = statify(done, totalSize, startTime)
|
||||||
progressInfo = fmt.Sprintf("%d/%d", i+1, len(reader.File))
|
progressInfo = fmt.Sprintf("%d/%d", i+1, len(reader.File))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue