From 3fe94482298e9eefca658b46078cecb220037121 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 5 Jun 2017 12:17:19 +0100 Subject: [PATCH] drive, acd, onedrive: Cache the directory IDs when reading the parent directory This makes directory listings much more efficient (one less transaction needed) and also fixes #1439 (which was caused by having to look up a directory name with quotes in which isn't dealt with well by the list routine) by not doing a directory lookup at all. --- amazonclouddrive/amazonclouddrive.go | 2 ++ drive/drive.go | 2 ++ onedrive/onedrive.go | 2 ++ 3 files changed, 6 insertions(+) diff --git a/amazonclouddrive/amazonclouddrive.go b/amazonclouddrive/amazonclouddrive.go index 9512903ec..89e88af7f 100644 --- a/amazonclouddrive/amazonclouddrive.go +++ b/amazonclouddrive/amazonclouddrive.go @@ -405,6 +405,8 @@ func (f *Fs) ListDir(out fs.ListOpts, job dircache.ListDirJob) (jobs []dircache. switch *node.Kind { case folderKind: if out.IncludeDirectory(remote) { + // cache the directory ID for later lookups + f.dirCache.Put(remote, *node.Id) dir := &fs.Dir{ Name: remote, Bytes: -1, diff --git a/drive/drive.go b/drive/drive.go index bb628e9cb..765f38c0d 100644 --- a/drive/drive.go +++ b/drive/drive.go @@ -564,6 +564,8 @@ func (f *Fs) ListDir(out fs.ListOpts, job dircache.ListDirJob) (jobs []dircache. // ignore object or directory case item.MimeType == driveFolderType: if out.IncludeDirectory(remote) { + // cache the directory ID for later lookups + f.dirCache.Put(remote, item.Id) dir := &fs.Dir{ Name: remote, Bytes: -1, diff --git a/onedrive/onedrive.go b/onedrive/onedrive.go index c89b322fe..208f9804e 100644 --- a/onedrive/onedrive.go +++ b/onedrive/onedrive.go @@ -406,6 +406,8 @@ func (f *Fs) ListDir(out fs.ListOpts, job dircache.ListDirJob) (jobs []dircache. remote := job.Path + info.Name if info.Folder != nil { if out.IncludeDirectory(remote) { + // cache the directory ID for later lookups + f.dirCache.Put(remote, info.ID) dir := &fs.Dir{ Name: remote, Bytes: -1,