Skip to content

Commit

Permalink
feat: Skip ignored files during compression instead of stopping with …
Browse files Browse the repository at this point in the history
…an error
  • Loading branch information
QuintenQVD0 committed Jul 17, 2024
1 parent 2f83e98 commit 95b0972
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions server/filesystem/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,21 @@ import (
// and the compressed file will be placed at that location named
// `archive-{date}.tar.gz`.
func (fs *Filesystem) CompressFiles(dir string, paths []string) (ufs.FileInfo, error) {
var validPaths []string
for _, file := range paths {
if err := fs.IsIgnored(path.Join(dir, file)); err != nil {
return nil, err
// file is in file denylist so skip it and continue to check the next files
continue
}
validPaths = append(validPaths, file)
}
a := &Archive{Filesystem: fs, BaseDirectory: dir, Files: paths}

// If there are no valid paths, return an error
if len(validPaths) == 0 {
return nil, fmt.Errorf("no valid files to compress")
}

a := &Archive{Filesystem: fs, BaseDirectory: dir, Files: validPaths}
d := path.Join(
dir,
fmt.Sprintf("archive-%s.tar.gz", strings.ReplaceAll(time.Now().Format(time.RFC3339), ":", "")),
Expand Down

0 comments on commit 95b0972

Please sign in to comment.