From a929eb10372f0a28cabbada1c491e3e6c9503ed7 Mon Sep 17 00:00:00 2001 From: Evan Su <48808396+HACKERALERT@users.noreply.github.com> Date: Mon, 27 Jan 2025 00:55:47 -0500 Subject: [PATCH] final auto unzip code tweaks --- src/Picocrypt.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Picocrypt.go b/src/Picocrypt.go index a2e69b9..be04bc9 100644 --- a/src/Picocrypt.go +++ b/src/Picocrypt.go @@ -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))