"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
drive: add `--drive-auth-owner-only` to only consider files owned by the user.
Björn Harrtell78edafcaac0f
diff --git a/docs/content/drive.md b/docs/content/drive.mdindex 87ea0f234..c7db53e16 100644--- a/docs/content/drive.md+++ b/docs/content/drive.md@@ -127,6 +127,11 @@ File size cutoff for switching to chunked upload. Default is 256kB.Send files to the trash instead of deleting permanently. Defaults tooff, namely deleting files permanently.+#### --drive-auth-owner-only ####++Only consider files owned by the authenticated user. Requires+that --drive-full-list=true (default).+### Limitations ###Drive has quite a lot of rate limiting. This causes rclone to bediff --git a/drive/drive.go b/drive/drive.goindex 59a379aa4..8c1d1fa43 100644--- a/drive/drive.go+++ b/drive/drive.go@@ -43,8 +43,9 @@ const (// Globalsvar (// Flags- driveFullList = pflag.BoolP("drive-full-list", "", true, "Use a full listing for directory list. More data but usually quicker.")- driveUseTrash = pflag.BoolP("drive-use-trash", "", false, "Send files to the trash instead of deleting permanently.")+ driveFullList = pflag.BoolP("drive-full-list", "", true, "Use a full listing for directory list. More data but usually quicker.")+ driveAuthOwnerOnly = pflag.BoolP("drive-auth-owner-only", "", false, "Only consider files owned by the authenticated user. Requires drive-full-list.")+ driveUseTrash = pflag.BoolP("drive-use-trash", "", false, "Send files to the trash instead of deleting permanently.")// chunkSize is the size of the chunks created during a resumable upload and should be a power of two.// 1<<18 is the minimum size supported by the Google uploader, and there is no maximum.chunkSize = fs.SizeSuffix(256 * 1024)@@ -400,6 +401,16 @@ func (f *Fs) listDirRecursive(dirID string, path string, out fs.ObjectsChan) errreturn nil}+// isAuthOwned checks if any of the item owners is the authenticated owner+func isAuthOwned(item *drive.File) bool {+ for _, owner := range item.Owners {+ if owner.IsAuthenticatedUser {+ return true+ }+ }+ return false+}+// Path should be directory path either "" or "path/"//// List the directory using a full listing and filtering out unwanted@@ -420,6 +431,9 @@ func (f *Fs) listDirFull(dirID string, path string, out fs.ObjectsChan) error {if directory != "" {path = directory + "/" + path}+ if *driveAuthOwnerOnly && !isAuthOwned(item) {+ return+ }if item.MimeType == driveFolderType {// Put the directory into the dircachef.dirCache.Put(path, item.Id)