Google Drive --drive-auth-owner-only-dirs to limit directory listed

Just thinking can I prepare PR with additional flag --drive-auth-owner-only-dirs that will ignore returning directories that current auth user is not owner of, would it be even merged to master?

(I assume I could also prepare one more flag --drive-auth-owner-only-all that would include both --drive-auth-owner-only and --drive-auth-owner-only-dirs)

I've prepared test branch on my fork, that is using old flag to ignore both but for backward compatibility I assume new flags would be better? Now it's two liner...

This is why we ignore directories. Note it is the exact reverse of your patch!

Unfortunately I didn't link this to an issue or the forum for further info...

commit 25bbc5d22b4e9c89ce40d5a3d7d2dfba0bb48640
Author: Nick Craig-Wood <nick@craig-wood.com>
Date:   Tue Feb 20 14:33:52 2018 +0000

    drive: make --drive-auth-owner-only look in all directories
    
    Previously it was ignoring directories which weren't owned by the user
    which meant it was ignoring files owned by the user in those
    directories.

diff --git a/backend/drive/drive.go b/backend/drive/drive.go
index e3f9c571e..b393ffccb 100644
--- a/backend/drive/drive.go
+++ b/backend/drive/drive.go
@@ -712,14 +712,14 @@ func (f *Fs) List(dir string) (entries fs.DirEntries, err error) {
        _, err = f.list(directoryID, "", false, false, false, func(item *drive.File) bool {
                remote := path.Join(dir, item.Name)
                switch {
-               case *driveAuthOwnerOnly && !isAuthOwned(item):
-                       // ignore object or directory
                case item.MimeType == driveFolderType:
                        // cache the directory ID for later lookups
                        f.dirCache.Put(remote, item.Id)
                        when, _ := time.Parse(timeFormatIn, item.ModifiedTime)
                        d := fs.NewDir(remote, when).SetID(item.Id)
                        entries = append(entries, d)
+               case *driveAuthOwnerOnly && !isAuthOwned(item):
+                       // ignore object
                case item.Md5Checksum != "" || item.Size > 0:
                        // If item has MD5 sum or a length it is a file stored on drive
                        o, err := f.newObjectWithInfo(remote, item)

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.