diff --git a/src/croc/croc.go b/src/croc/croc.go index 8588c8cd..c51cbcd4 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -286,7 +286,8 @@ func GetFilesInfo(fnames []string, zipfolder bool) (filesInfo []FileInfo, emptyF } if stat.IsDir() && zipfolder { - dest := path + ".zip" + path := filepath.Dir(path) + dest := filepath.Base(path) + ".zip" utils.ZipDirectory(dest, path) stat, errStat = os.Lstat(dest) if errStat != nil { diff --git a/src/utils/utils.go b/src/utils/utils.go index 29bc6c88..9dce321f 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -394,7 +394,8 @@ func ZipDirectory(destination string, source string) (err error) { log.Fatalln(err) } defer f1.Close() - w1, err := writer.Create(path) + zip_path := strings.ReplaceAll(path, source, strings.TrimSuffix(destination, ".zip")) + w1, err := writer.Create(zip_path) if err != nil { log.Fatalln(err) } @@ -402,7 +403,7 @@ func ZipDirectory(destination string, source string) (err error) { log.Fatalln(err) } fmt.Fprintf(os.Stderr, "\r\033[2K") - fmt.Fprintf(os.Stderr, "\rAdding %s", path) + fmt.Fprintf(os.Stderr, "\rAdding %s", zip_path) } return nil })