drive: add --drive-auth-owner-only
to only consider files owned by the user.
This commit is contained in:
parent
1ce3673006
commit
78edafcaac
2 changed files with 21 additions and 2 deletions
|
@ -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 to
|
Send files to the trash instead of deleting permanently. Defaults to
|
||||||
off, namely deleting files permanently.
|
off, namely deleting files permanently.
|
||||||
|
|
||||||
|
#### --drive-auth-owner-only ####
|
||||||
|
|
||||||
|
Only consider files owned by the authenticated user. Requires
|
||||||
|
that --drive-full-list=true (default).
|
||||||
|
|
||||||
### Limitations ###
|
### Limitations ###
|
||||||
|
|
||||||
Drive has quite a lot of rate limiting. This causes rclone to be
|
Drive has quite a lot of rate limiting. This causes rclone to be
|
||||||
|
|
|
@ -44,6 +44,7 @@ const (
|
||||||
var (
|
var (
|
||||||
// Flags
|
// Flags
|
||||||
driveFullList = pflag.BoolP("drive-full-list", "", true, "Use a full listing for directory list. More data but usually quicker.")
|
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.")
|
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.
|
// 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.
|
// 1<<18 is the minimum size supported by the Google uploader, and there is no maximum.
|
||||||
|
@ -400,6 +401,16 @@ func (f *Fs) listDirRecursive(dirID string, path string, out fs.ObjectsChan) err
|
||||||
return nil
|
return 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/"
|
// Path should be directory path either "" or "path/"
|
||||||
//
|
//
|
||||||
// List the directory using a full listing and filtering out unwanted
|
// 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 != "" {
|
if directory != "" {
|
||||||
path = directory + "/" + path
|
path = directory + "/" + path
|
||||||
}
|
}
|
||||||
|
if *driveAuthOwnerOnly && !isAuthOwned(item) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if item.MimeType == driveFolderType {
|
if item.MimeType == driveFolderType {
|
||||||
// Put the directory into the dircache
|
// Put the directory into the dircache
|
||||||
f.dirCache.Put(path, item.Id)
|
f.dirCache.Put(path, item.Id)
|
||||||
|
|
Loading…
Reference in a new issue