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
This commit is contained in:
Brad Fitzpatrick 2018-05-09 10:01:14 -07:00
parent 2e052c5fe5
commit d50667a178
1 changed files with 7 additions and 3 deletions

View File

@ -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() }