diff --git a/docs/content/drive.md b/docs/content/drive.md index 21f8aea3e..5081e0519 100644 --- a/docs/content/drive.md +++ b/docs/content/drive.md @@ -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 #### diff --git a/drive/drive.go b/drive/drive.go index 015fddb3c..9ec3f0dee 100644 --- a/drive/drive.go +++ b/drive/drive.go @@ -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)