1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 10:33:34 +00:00

Add placeholder support for ListR interface.

The ListR interface will be implemented by remotes that can do a
recursive directory listing more efficiently than just recursing
through the directories.  These include the bucket based remotes.
This commit is contained in:
Nick Craig-Wood
2017-06-05 16:14:24 +01:00
parent 0edb025257
commit 53c3e5f0ab
7 changed files with 75 additions and 2 deletions

View File

@@ -295,6 +295,19 @@ type Features struct {
// Implement this if you have a way of emptying the trash or
// otherwise cleaning up old versions of files.
CleanUp func() error
// ListR lists the objects and directories of the Fs starting
// from dir recursively into out.
//
// dir should be "" to start from the root, and should not
// have trailing slashes.
//
// This should return ErrDirNotFound (using out.SetError())
// if the directory isn't found.
//
// Don't implement this unless you have a more efficient way
// of listing recursively that doing a directory traversal.
ListR func(out ListOpts, dir string)
}
// Fill fills in the function pointers in the Features struct from the
@@ -328,6 +341,9 @@ func (ft *Features) Fill(f Fs) *Features {
if do, ok := f.(CleanUpper); ok {
ft.CleanUp = do.CleanUp
}
if do, ok := f.(ListRer); ok {
ft.ListR = do.ListR
}
return ft
}
@@ -370,6 +386,9 @@ func (ft *Features) Mask(f Fs) *Features {
if mask.CleanUp == nil {
ft.CleanUp = nil
}
if mask.ListR == nil {
ft.ListR = nil
}
return ft
}
@@ -479,6 +498,22 @@ type CleanUpper interface {
CleanUp() error
}
// ListRer is an optional interfaces for Fs
type ListRer interface {
// ListR lists the objects and directories of the Fs starting
// from dir recursively into out.
//
// dir should be "" to start from the root, and should not
// have trailing slashes.
//
// This should return ErrDirNotFound (using out.SetError())
// if the directory isn't found.
//
// Don't implement this unless you have a more efficient way
// of listing recursively that doing a directory traversal.
ListR(out ListOpts, dir string)
}
// ObjectsChan is a channel of Objects
type ObjectsChan chan Object