From 7daa850d44dd2154e05ff5d178c8f0f3667a6119 Mon Sep 17 00:00:00 2001 From: Brian Bland Date: Tue, 4 Nov 2014 09:52:24 -0800 Subject: [PATCH] Fixes documentation to show that StorageDriver.List is non-recursive --- storagedriver/filesystem/filesystem.go | 8 ++++---- storagedriver/inmemory/inmemory.go | 4 ++-- storagedriver/ipc/client.go | 4 ++-- storagedriver/ipc/server.go | 4 ++-- storagedriver/storagedriver.go | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/storagedriver/filesystem/filesystem.go b/storagedriver/filesystem/filesystem.go index 4f100dd3d..0bdf60177 100644 --- a/storagedriver/filesystem/filesystem.go +++ b/storagedriver/filesystem/filesystem.go @@ -166,9 +166,9 @@ func (d *FilesystemDriver) ResumeWritePosition(subPath string) (uint64, error) { return uint64(fileInfo.Size()), nil } -func (d *FilesystemDriver) List(prefix string) ([]string, error) { - prefix = strings.TrimRight(prefix, "/") - fullPath := d.subPath(prefix) +func (d *FilesystemDriver) List(subPath string) ([]string, error) { + subPath = strings.TrimRight(subPath, "/") + fullPath := d.subPath(subPath) dir, err := os.Open(fullPath) if err != nil { @@ -182,7 +182,7 @@ func (d *FilesystemDriver) List(prefix string) ([]string, error) { keys := make([]string, 0, len(fileNames)) for _, fileName := range fileNames { - keys = append(keys, path.Join(prefix, fileName)) + keys = append(keys, path.Join(subPath, fileName)) } return keys, nil diff --git a/storagedriver/inmemory/inmemory.go b/storagedriver/inmemory/inmemory.go index d7d4ccea2..9b9fd9473 100644 --- a/storagedriver/inmemory/inmemory.go +++ b/storagedriver/inmemory/inmemory.go @@ -110,8 +110,8 @@ func (d *InMemoryDriver) ResumeWritePosition(path string) (uint64, error) { return uint64(len(contents)), nil } -func (d *InMemoryDriver) List(prefix string) ([]string, error) { - subPathMatcher, err := regexp.Compile(fmt.Sprintf("^%s/[^/]+", prefix)) +func (d *InMemoryDriver) List(path string) ([]string, error) { + subPathMatcher, err := regexp.Compile(fmt.Sprintf("^%s/[^/]+", path)) if err != nil { return nil, err } diff --git a/storagedriver/ipc/client.go b/storagedriver/ipc/client.go index 54090945e..fd5f15c32 100644 --- a/storagedriver/ipc/client.go +++ b/storagedriver/ipc/client.go @@ -240,10 +240,10 @@ func (driver *StorageDriverClient) ResumeWritePosition(path string) (uint64, err return response.Position, nil } -func (driver *StorageDriverClient) List(prefix string) ([]string, error) { +func (driver *StorageDriverClient) List(path string) ([]string, error) { receiver, remoteSender := libchan.Pipe() - params := map[string]interface{}{"Prefix": prefix} + params := map[string]interface{}{"Path": path} err := driver.sender.Send(&Request{Type: "List", Parameters: params, ResponseChannel: remoteSender}) if err != nil { return nil, err diff --git a/storagedriver/ipc/server.go b/storagedriver/ipc/server.go index 989b44ba7..d73be2f6d 100644 --- a/storagedriver/ipc/server.go +++ b/storagedriver/ipc/server.go @@ -131,8 +131,8 @@ func handleRequest(driver storagedriver.StorageDriver, request Request) { panic(err) } case "List": - prefix, _ := request.Parameters["Prefix"].(string) - keys, err := driver.List(prefix) + path, _ := request.Parameters["Path"].(string) + keys, err := driver.List(path) response := ListResponse{ Keys: keys, Error: ResponseError(err), diff --git a/storagedriver/storagedriver.go b/storagedriver/storagedriver.go index 57e34c0df..a66dba0c2 100644 --- a/storagedriver/storagedriver.go +++ b/storagedriver/storagedriver.go @@ -32,8 +32,8 @@ type StorageDriver interface { // given path ResumeWritePosition(path string) (uint64, error) - // List recursively lists the objects stored at a subpath of the given prefix - List(prefix string) ([]string, error) + // List returns a list of the objects that are direct descendants of the given path + List(path string) ([]string, error) // Move moves an object stored at sourcePath to destPath, removing the original object // Note: This may be no more efficient than a copy followed by a delete for many implementations