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
+7 -4
View File
@@ -5,10 +5,12 @@ import (
"io"
"os"
"path/filepath"
"sort"
"sync"
"syscall"
"github.com/pborman/uuid"
"github.com/saracen/walker"
"github.com/aptly-dev/aptly/aptly"
"github.com/aptly-dev/aptly/utils"
@@ -98,13 +100,13 @@ func (pool *PackagePool) FilepathList(progress aptly.Progress) ([]string, error)
}
result := []string{}
resultLock := &sync.Mutex{}
for _, dir := range dirs {
err = filepath.Walk(filepath.Join(pool.rootPath, dir.Name()), func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
err = walker.Walk(filepath.Join(pool.rootPath, dir.Name()), func(path string, info os.FileInfo) error {
if !info.IsDir() {
resultLock.Lock()
defer resultLock.Unlock()
result = append(result, path[len(pool.rootPath)+1:])
}
return nil
@@ -118,6 +120,7 @@ func (pool *PackagePool) FilepathList(progress aptly.Progress) ([]string, error)
}
}
sort.Strings(result)
return result, nil
}