Skip to content

Commit

Permalink
Added support for sending relative folder
Browse files Browse the repository at this point in the history
  • Loading branch information
stefins committed Jul 6, 2022
1 parent 37ae453 commit b50fe88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/croc/croc.go
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions src/utils/utils.go
Expand Up @@ -394,15 +394,16 @@ 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)
}
if _, err := io.Copy(w1, f1); err != nil {
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
})
Expand Down

0 comments on commit b50fe88

Please sign in to comment.