From 7096b3dab92441981c9964e4a6175af0a255d2be Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Wed, 4 Nov 2020 14:32:52 +0000 Subject: [PATCH] fix: empty folder in archive --- http/raw.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/http/raw.go b/http/raw.go index b340165a..12b51536 100644 --- a/http/raw.go +++ b/http/raw.go @@ -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() {