From 68ab705aacc70649612b0fbcd9d8fab11d6fab36 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 27 Aug 2020 19:55:43 -0700 Subject: [PATCH] Don't push directories into the backup unless associated with a file --- server/filesystem.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/filesystem.go b/server/filesystem.go index d23db19..6effbc3 100644 --- a/server/filesystem.go +++ b/server/filesystem.go @@ -773,10 +773,13 @@ func (fs *Filesystem) GetIncludedFiles(dir string, ignored []string) (*backup.In } } - // Avoid unnecessary parsing if there are no ignored files, nothing will match anyways - // so no reason to call the function. - if len(ignored) == 0 || !i.MatchesPath(strings.TrimPrefix(sp, fs.Path()+"/")) { - inc.Push(sp) + // Only push files into the result array since archives can't create an empty directory within them. + if !e.IsDir() { + // Avoid unnecessary parsing if there are no ignored files, nothing will match anyways + // so no reason to call the function. + if len(ignored) == 0 || !i.MatchesPath(strings.TrimPrefix(sp, fs.Path()+"/")) { + inc.Push(sp) + } } // We can't just abort if the path is technically ignored. It is possible there is a nested