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.
This commit is contained in:
Nick Craig-Wood 2017-06-05 12:17:19 +01:00
parent a5cfdfd233
commit 3fe9448229
3 changed files with 6 additions and 0 deletions

View file

@ -405,6 +405,8 @@ func (f *Fs) ListDir(out fs.ListOpts, job dircache.ListDirJob) (jobs []dircache.
switch *node.Kind { switch *node.Kind {
case folderKind: case folderKind:
if out.IncludeDirectory(remote) { if out.IncludeDirectory(remote) {
// cache the directory ID for later lookups
f.dirCache.Put(remote, *node.Id)
dir := &fs.Dir{ dir := &fs.Dir{
Name: remote, Name: remote,
Bytes: -1, Bytes: -1,

View file

@ -564,6 +564,8 @@ func (f *Fs) ListDir(out fs.ListOpts, job dircache.ListDirJob) (jobs []dircache.
// ignore object or directory // ignore object or directory
case item.MimeType == driveFolderType: case item.MimeType == driveFolderType:
if out.IncludeDirectory(remote) { if out.IncludeDirectory(remote) {
// cache the directory ID for later lookups
f.dirCache.Put(remote, item.Id)
dir := &fs.Dir{ dir := &fs.Dir{
Name: remote, Name: remote,
Bytes: -1, Bytes: -1,

View file

@ -406,6 +406,8 @@ func (f *Fs) ListDir(out fs.ListOpts, job dircache.ListDirJob) (jobs []dircache.
remote := job.Path + info.Name remote := job.Path + info.Name
if info.Folder != nil { if info.Folder != nil {
if out.IncludeDirectory(remote) { if out.IncludeDirectory(remote) {
// cache the directory ID for later lookups
f.dirCache.Put(remote, info.ID)
dir := &fs.Dir{ dir := &fs.Dir{
Name: remote, Name: remote,
Bytes: -1, Bytes: -1,