1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 02:23:24 +00:00

Add a directory parameter to Fs.List()

This commit is contained in:
Nick Craig-Wood
2016-04-23 21:46:52 +01:00
parent 753b0717be
commit 68ec6a9f5b
31 changed files with 263 additions and 230 deletions

View File

@@ -235,14 +235,22 @@ func (f *Fs) stripRoot(path string) (string, error) {
}
// Walk the root returning a channel of FsObjects
func (f *Fs) list(out fs.ListOpts) {
func (f *Fs) list(out fs.ListOpts, dir string) {
// Track path component case, it could be different for entries coming from DropBox API
// See https://www.dropboxforum.com/hc/communities/public/questions/201665409-Wrong-character-case-of-folder-name-when-calling-listFolder-using-Sync-API?locale=en-us
// and https://github.com/ncw/rclone/issues/53
nameTree := newNameTree()
cursor := ""
root := f.slashRoot
if dir != "" {
root += "/" + dir
// We assume that dir is entered in the correct case
// here which is likely since it probably came from a
// directory listing
nameTree.PutCaseCorrectPath(strings.Trim(root, "/"))
}
for {
deltaPage, err := f.db.Delta(cursor, f.slashRoot)
deltaPage, err := f.db.Delta(cursor, root)
if err != nil {
fs.Stats.Error()
fs.ErrorLog(f, "Couldn't list: %s", err)
@@ -340,9 +348,9 @@ func (f *Fs) list(out fs.ListOpts) {
}
// List walks the path returning a channel of FsObjects
func (f *Fs) List(out fs.ListOpts) {
func (f *Fs) List(out fs.ListOpts, dir string) {
defer out.Finished()
f.list(out)
f.list(out, dir)
}
// ListDir walks the path returning a channel of FsObjects