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
|
||||
startTime := time.Now()
|
||||
|
||||
for i, f := range reader.File {
|
||||
outPath := filepath.Join(extractDir, f.Name)
|
||||
for _, f := range reader.File {
|
||||
outPath := filepath.Join(extractDir, filepath.Clean(strings.ReplaceAll(f.Name, "\\", "/")))
|
||||
|
||||
// Make directory if current entry is a folder
|
||||
if f.FileInfo().IsDir() {
|
||||
if err := os.MkdirAll(outPath, f.Mode()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i, f := range reader.File {
|
||||
// Already handled above
|
||||
if f.FileInfo().IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
outPath := filepath.Join(extractDir, filepath.Clean(strings.ReplaceAll(f.Name, "\\", "/")))
|
||||
|
||||
// Otherwise create necessary parent directories
|
||||
if err := os.MkdirAll(filepath.Dir(outPath), 0755); err != nil {
|
||||
return err
|
||||
|
@ -2426,7 +2434,6 @@ func unpackArchive(zipPath string) error {
|
|||
return writeErr
|
||||
}
|
||||
|
||||
// Update "done" and recalc progress, speed, eta
|
||||
done += int64(n)
|
||||
progress, speed, eta = statify(done, totalSize, startTime)
|
||||
progressInfo = fmt.Sprintf("%d/%d", i+1, len(reader.File))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue