mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
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:
committed by
André Roth
parent
53c4a567c0
commit
8ab8398c50
+8
-4
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user