drive: Make --drive-trashed-only show all directories - fixes #1524

Without showing all directories it doesn't show trashed files which
are in an untrashed directory.

This isn't an ideal fix, but it makes the feature useable.
This commit is contained in:
Nick Craig-Wood 2017-07-19 14:35:58 +01:00
parent db5494b316
commit 39d09c04a2
2 changed files with 8 additions and 3 deletions

View File

@ -256,7 +256,8 @@ Skip google documents in all listings. If given, gdocs practically become invisi
#### --drive-trashed-only ####
Only show files that are in the trash
Only show files that are in the trash. This will show trashed files
in their original directory structure.
#### --drive-upload-cutoff=SIZE ####

View File

@ -216,7 +216,11 @@ type listFn func(*drive.File) bool
func (f *Fs) list(dirID string, title string, directoriesOnly bool, filesOnly bool, includeAll bool, fn listFn) (found bool, err error) {
var query []string
if !includeAll {
query = append(query, "trashed="+strconv.FormatBool(*driveTrashedOnly))
q := "trashed=" + strconv.FormatBool(*driveTrashedOnly)
if *driveTrashedOnly {
q = fmt.Sprintf("(mimeType='%s' or %s)", driveFolderType, q)
}
query = append(query, q)
}
// 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
@ -241,10 +245,10 @@ func (f *Fs) list(dirID string, title string, directoriesOnly bool, filesOnly bo
if filesOnly {
query = append(query, fmt.Sprintf("mimeType!='%s'", driveFolderType))
}
// fmt.Printf("list Query = %q\n", query)
list := f.svc.Files.List()
if len(query) > 0 {
list = list.Q(strings.Join(query, " and "))
// fmt.Printf("list Query = %q\n", query)
}
if *driveListChunk > 0 {
list = list.MaxResults(*driveListChunk)