From d50667a1788f67a91f267ca09e0e51dd39fe6042 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 9 May 2018 10:01:14 -0700 Subject: [PATCH] blobserver/files: fix a data race in os.FileInfo stat readahead And fix some log messages to remove "localdisk", since this code is now shared by sftp and in the future will be shared by webdav, ftps, etc. Change-Id: I4c428cdd6c90bb509045d1914922326a10f48a17 --- pkg/blobserver/files/enumerate.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/blobserver/files/enumerate.go b/pkg/blobserver/files/enumerate.go index 81af23eb3..1dc2fee18 100644 --- a/pkg/blobserver/files/enumerate.go +++ b/pkg/blobserver/files/enumerate.go @@ -45,7 +45,7 @@ type enumerateError struct { } func (ee *enumerateError) Error() string { - return fmt.Sprintf("localdisk enumerate error: %s: %v", ee.msg, ee.err) + return fmt.Sprintf("files enumerate error: %s: %v", ee.msg, ee.err) } // readBlobs implements EnumerateBlobs. It calls itself recursively on subdirectories. @@ -80,7 +80,7 @@ func (ds *Storage) readBlobs(ctx context.Context, opts readBlobRequest) error { return fi, nil }) stat[name] = f - toStat = append(toStat, f.run) + toStat = append(toStat, f.ForceLoad) } // Start pre-statting things. @@ -168,7 +168,7 @@ func (ds *Storage) readBlobs(ctx context.Context, opts readBlobRequest) error { func (ds *Storage) EnumerateBlobs(ctx context.Context, dest chan<- blob.SizedRef, after string, limit int) error { defer close(dest) if limit == 0 { - log.Printf("Warning: localdisk.EnumerateBlobs called with a limit of 0") + log.Printf("Warning: files.EnumerateBlobs called with a limit of 0") } limitMutable := limit @@ -213,4 +213,8 @@ func (f *future) Get() (os.FileInfo, error) { return f.v, f.err } +func (f *future) ForceLoad() { + f.Get() +} + func (f *future) run() { f.v, f.err = f.f() }