Fixes documentation to show that StorageDriver.List is non-recursive
This commit is contained in:
parent
43716a2850
commit
7daa850d44
5 changed files with 12 additions and 12 deletions
|
@ -166,9 +166,9 @@ func (d *FilesystemDriver) ResumeWritePosition(subPath string) (uint64, error) {
|
||||||
return uint64(fileInfo.Size()), nil
|
return uint64(fileInfo.Size()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *FilesystemDriver) List(prefix string) ([]string, error) {
|
func (d *FilesystemDriver) List(subPath string) ([]string, error) {
|
||||||
prefix = strings.TrimRight(prefix, "/")
|
subPath = strings.TrimRight(subPath, "/")
|
||||||
fullPath := d.subPath(prefix)
|
fullPath := d.subPath(subPath)
|
||||||
|
|
||||||
dir, err := os.Open(fullPath)
|
dir, err := os.Open(fullPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -182,7 +182,7 @@ func (d *FilesystemDriver) List(prefix string) ([]string, error) {
|
||||||
|
|
||||||
keys := make([]string, 0, len(fileNames))
|
keys := make([]string, 0, len(fileNames))
|
||||||
for _, fileName := range fileNames {
|
for _, fileName := range fileNames {
|
||||||
keys = append(keys, path.Join(prefix, fileName))
|
keys = append(keys, path.Join(subPath, fileName))
|
||||||
}
|
}
|
||||||
|
|
||||||
return keys, nil
|
return keys, nil
|
||||||
|
|
|
@ -110,8 +110,8 @@ func (d *InMemoryDriver) ResumeWritePosition(path string) (uint64, error) {
|
||||||
return uint64(len(contents)), nil
|
return uint64(len(contents)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *InMemoryDriver) List(prefix string) ([]string, error) {
|
func (d *InMemoryDriver) List(path string) ([]string, error) {
|
||||||
subPathMatcher, err := regexp.Compile(fmt.Sprintf("^%s/[^/]+", prefix))
|
subPathMatcher, err := regexp.Compile(fmt.Sprintf("^%s/[^/]+", path))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,10 +240,10 @@ func (driver *StorageDriverClient) ResumeWritePosition(path string) (uint64, err
|
||||||
return response.Position, nil
|
return response.Position, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver *StorageDriverClient) List(prefix string) ([]string, error) {
|
func (driver *StorageDriverClient) List(path string) ([]string, error) {
|
||||||
receiver, remoteSender := libchan.Pipe()
|
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})
|
err := driver.sender.Send(&Request{Type: "List", Parameters: params, ResponseChannel: remoteSender})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -131,8 +131,8 @@ func handleRequest(driver storagedriver.StorageDriver, request Request) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
case "List":
|
case "List":
|
||||||
prefix, _ := request.Parameters["Prefix"].(string)
|
path, _ := request.Parameters["Path"].(string)
|
||||||
keys, err := driver.List(prefix)
|
keys, err := driver.List(path)
|
||||||
response := ListResponse{
|
response := ListResponse{
|
||||||
Keys: keys,
|
Keys: keys,
|
||||||
Error: ResponseError(err),
|
Error: ResponseError(err),
|
||||||
|
|
|
@ -32,8 +32,8 @@ type StorageDriver interface {
|
||||||
// given path
|
// given path
|
||||||
ResumeWritePosition(path string) (uint64, error)
|
ResumeWritePosition(path string) (uint64, error)
|
||||||
|
|
||||||
// List recursively lists the objects stored at a subpath of the given prefix
|
// List returns a list of the objects that are direct descendants of the given path
|
||||||
List(prefix string) ([]string, error)
|
List(path string) ([]string, error)
|
||||||
|
|
||||||
// Move moves an object stored at sourcePath to destPath, removing the original object
|
// 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
|
// Note: This may be no more efficient than a copy followed by a delete for many implementations
|
||||||
|
|
Loading…
Add table
Reference in a new issue