Skip to content

Commit

Permalink
fix: empty folder in archive
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiresviana committed Nov 4, 2020
1 parent 36cacdf commit 7096b3d
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions http/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,19 @@ func addFile(ar archiver.Writer, d *data, path, commonPath string) error {
}
defer file.Close()

filename := strings.TrimPrefix(path, commonPath)
filename = strings.TrimPrefix(filename, "/")
err = ar.Write(archiver.File{
FileInfo: archiver.FileInfo{
FileInfo: info,
CustomName: filename,
},
ReadCloser: file,
})
if err != nil {
return err
if path != commonPath {
filename := strings.TrimPrefix(path, commonPath)
filename = strings.TrimPrefix(filename, "/")
err = ar.Write(archiver.File{
FileInfo: archiver.FileInfo{
FileInfo: info,
CustomName: filename,
},
ReadCloser: file,
})
if err != nil {
return err
}
}

if info.IsDir() {
Expand Down

0 comments on commit 7096b3d

Please sign in to comment.