drive: Add --drive-trashed-only and remove obsolete --drive-full-list

* Add --drive-trashed-only to show only the contents of the trash
  * Remove --drive-full-list as it is obsolete
  * Tidy the docs for the drive options
This commit is contained in:
Nick Craig-Wood 2017-07-06 15:32:57 +01:00
parent 69ff009264
commit 92294a4a92
2 changed files with 32 additions and 21 deletions

View File

@ -178,6 +178,10 @@ sending them to the trash is required instead then use the
Here are the command line options specific to this cloud storage Here are the command line options specific to this cloud storage
system. system.
#### --drive-auth-owner-only ####
Only consider files owned by the authenticated user.
#### --drive-chunk-size=SIZE #### #### --drive-chunk-size=SIZE ####
Upload chunk size. Must a power of 2 >= 256k. Default value is 8 MB. Upload chunk size. Must a power of 2 >= 256k. Default value is 8 MB.
@ -187,23 +191,9 @@ is buffered in memory one per transfer.
Reducing this will reduce memory usage but decrease performance. Reducing this will reduce memory usage but decrease performance.
#### --drive-full-list ####
No longer does anything - kept for backwards compatibility.
#### --drive-upload-cutoff=SIZE ####
File size cutoff for switching to chunked upload. Default is 8 MB.
#### --drive-use-trash ####
Send files to the trash instead of deleting permanently. Defaults to
off, namely deleting files permanently.
#### --drive-auth-owner-only #### #### --drive-auth-owner-only ####
Only consider files owned by the authenticated user. Requires Only consider files owned by the authenticated user.
that --drive-full-list=true (default).
#### --drive-formats #### #### --drive-formats ####
@ -252,10 +242,31 @@ Here are the possible extensions with their corresponding mime types.
| xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | Microsoft Office Spreadsheet | | xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | Microsoft Office Spreadsheet |
| zip | application/zip | A ZIP file of HTML, Images CSS | | zip | application/zip | A ZIP file of HTML, Images CSS |
#### --drive-list-chunk int ####
Size of listing chunk 100-1000. 0 to disable. (default 1000)
#### --drive-shared-with-me ####
Only show files that are shared with me
#### --drive-skip-gdocs #### #### --drive-skip-gdocs ####
Skip google documents in all listings. If given, gdocs practically become invisible to rclone. Skip google documents in all listings. If given, gdocs practically become invisible to rclone.
#### --drive-trashed-only ####
Only show files that are in the trash
#### --drive-upload-cutoff=SIZE ####
File size cutoff for switching to chunked upload. Default is 8 MB.
#### --drive-use-trash ####
Send files to the trash instead of deleting permanently. Defaults to
off, namely deleting files permanently.
### 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

View File

@ -14,6 +14,7 @@ import (
"net/http" "net/http"
"path" "path"
"sort" "sort"
"strconv"
"strings" "strings"
"time" "time"
@ -43,11 +44,11 @@ const (
// Globals // Globals
var ( var (
// Flags // Flags
driveFullList = fs.BoolP("drive-full-list", "", false, "Use a full listing for directory list. More data but usually quicker. (obsolete)") driveAuthOwnerOnly = fs.BoolP("drive-auth-owner-only", "", false, "Only consider files owned by the authenticated user.")
driveAuthOwnerOnly = fs.BoolP("drive-auth-owner-only", "", false, "Only consider files owned by the authenticated user. Requires drive-full-list.")
driveUseTrash = fs.BoolP("drive-use-trash", "", false, "Send files to the trash instead of deleting permanently.") driveUseTrash = fs.BoolP("drive-use-trash", "", false, "Send files to the trash instead of deleting permanently.")
driveSkipGdocs = fs.BoolP("drive-skip-gdocs", "", false, "Skip google documents in all listings.") driveSkipGdocs = fs.BoolP("drive-skip-gdocs", "", false, "Skip google documents in all listings.")
driveSharedWithMe = fs.BoolP("drive-shared-with-me", "", false, "Only show files that are shared with me") driveSharedWithMe = fs.BoolP("drive-shared-with-me", "", false, "Only show files that are shared with me")
driveTrashedOnly = fs.BoolP("drive-trashed-only", "", false, "Only show files that are in the trash")
driveExtensions = fs.StringP("drive-formats", "", defaultExtensions, "Comma separated list of preferred formats for downloading Google docs.") driveExtensions = fs.StringP("drive-formats", "", defaultExtensions, "Comma separated list of preferred formats for downloading Google docs.")
driveListChunk = pflag.Int64P("drive-list-chunk", "", 1000, "Size of listing chunk 100-1000. 0 to disable.") driveListChunk = pflag.Int64P("drive-list-chunk", "", 1000, "Size of listing chunk 100-1000. 0 to disable.")
// 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.
@ -212,11 +213,10 @@ type listFn func(*drive.File) bool
// If the user fn ever returns true then it early exits with found = true // If the user fn ever returns true then it early exits with found = true
// //
// Search params: https://developers.google.com/drive/search-parameters // Search params: https://developers.google.com/drive/search-parameters
func (f *Fs) list(dirID string, title string, directoriesOnly bool, filesOnly bool, includeTrashed bool, fn listFn) (found bool, err error) { func (f *Fs) list(dirID string, title string, directoriesOnly bool, filesOnly bool, includeAll bool, fn listFn) (found bool, err error) {
var query []string var query []string
if !includeAll {
if !includeTrashed { query = append(query, "trashed="+strconv.FormatBool(*driveTrashedOnly))
query = append(query, "trashed=false")
} }
// Search with sharedWithMe will always return things listed in "Shared With Me" (without any parents) // Search with sharedWithMe will always return things listed in "Shared With Me" (without any parents)
// We must not filter with parent when we try list "ROOT" with drive-shared-with-me // We must not filter with parent when we try list "ROOT" with drive-shared-with-me