From b9024e06795906fa74925065cef81d094af95fc0 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Wed, 6 May 2015 17:10:35 -0400 Subject: [PATCH] 5748: Clean up comments and variable names. --- services/keepstore/volume_test.go | 2 +- services/keepstore/volume_unix.go | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/services/keepstore/volume_test.go b/services/keepstore/volume_test.go index b0cbabf800..66e0810c97 100644 --- a/services/keepstore/volume_test.go +++ b/services/keepstore/volume_test.go @@ -109,7 +109,7 @@ func (v *MockVolume) Mtime(loc string) (time.Time, error) { } func (v *MockVolume) IndexTo(prefix string, w io.Writer) error { - v.gotCall("Index") + v.gotCall("IndexTo") for loc, block := range v.Store { if !IsValidLocator(loc) || !strings.HasPrefix(loc, prefix) { continue diff --git a/services/keepstore/volume_unix.go b/services/keepstore/volume_unix.go index 7df0b11245..8d23d11618 100644 --- a/services/keepstore/volume_unix.go +++ b/services/keepstore/volume_unix.go @@ -218,7 +218,7 @@ func (v *UnixVolume) Status() *VolumeStatus { // IndexTo writes (to the given Writer) a list of blocks found on this // volume which begin with the specified prefix. If the prefix is an -// empty string, Index writes a complete list of blocks. +// empty string, IndexTo writes a complete list of blocks. // // Each block is given in the format // @@ -238,24 +238,22 @@ func (v *UnixVolume) IndexTo(prefix string, w io.Writer) error { v, path, err) return nil } - locator := filepath.Base(path) - // Skip directories that do not match prefix. - // We know there is nothing interesting inside. + basename := filepath.Base(path) if info.IsDir() && - !strings.HasPrefix(locator, prefix) && - !strings.HasPrefix(prefix, locator) { + !strings.HasPrefix(basename, prefix) && + !strings.HasPrefix(prefix, basename) { + // Skip directories that do not match + // prefix. We know there is nothing + // interesting inside. return filepath.SkipDir } - // Skip any file that is not apparently a locator, e.g. .meta files - if info.IsDir() || !IsValidLocator(locator) { - return nil - } - // Print filenames beginning with prefix - if !strings.HasPrefix(locator, prefix) { + if info.IsDir() || + !IsValidLocator(basename) || + !strings.HasPrefix(basename, prefix) { return nil } _, err = fmt.Fprintf(w, "%s+%d %d\n", - locator, info.Size(), info.ModTime().Unix()) + basename, info.Size(), info.ModTime().Unix()) return err }) } -- 2.30.2