Use github.com/saracen/walker for file walk operations

In some local tests w/ a slowed down filesystem, this massively cut down
on the time to clean up a repository by ~3x, bringing a total 'publish
update' time from ~16s to ~13s.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
This commit is contained in:
Ryan Gonzalez
2023-09-05 15:22:24 -05:00
committed by André Roth
parent 53c4a567c0
commit 8ab8398c50
7 changed files with 48 additions and 21 deletions
+8 -4
View File
@@ -5,11 +5,14 @@ import (
"io"
"os"
"path/filepath"
"sort"
"strings"
"sync"
"syscall"
"github.com/aptly-dev/aptly/aptly"
"github.com/aptly-dev/aptly/utils"
"github.com/saracen/walker"
)
// PublishedStorage abstract file system with public dirs (published repos)
@@ -232,12 +235,12 @@ func (storage *PublishedStorage) LinkFromPool(publishedPrefix, publishedRelPath,
func (storage *PublishedStorage) Filelist(prefix string) ([]string, error) {
root := filepath.Join(storage.rootPath, prefix)
result := []string{}
resultLock := &sync.Mutex{}
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
err := walker.Walk(root, func(path string, info os.FileInfo) error {
if !info.IsDir() {
resultLock.Lock()
defer resultLock.Unlock()
result = append(result, path[len(root)+1:])
}
return nil
@@ -248,6 +251,7 @@ func (storage *PublishedStorage) Filelist(prefix string) ([]string, error) {
return []string{}, nil
}
sort.Strings(result)
return result, err
}