drive: only request owner field when using --drive-auth-owner-only
This fixes the note @ncw made in #1359
This commit is contained in:
parent
7d9faffd4b
commit
0d6e1afe54
1 changed files with 11 additions and 2 deletions
|
@ -84,7 +84,7 @@ var (
|
||||||
"text/tab-separated-values": "tsv",
|
"text/tab-separated-values": "tsv",
|
||||||
}
|
}
|
||||||
extensionToMimeType map[string]string
|
extensionToMimeType map[string]string
|
||||||
partialFields = googleapi.Field("items(id,downloadUrl,exportLinks,fileExtension,fullFileExtension,fileSize,labels,md5Checksum,modifiedDate,mimeType,title,owners)")
|
partialFields = "items(id,downloadUrl,exportLinks,fileExtension,fullFileExtension,fileSize,labels,md5Checksum,modifiedDate,mimeType,title%s)"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register with Fs
|
// Register with Fs
|
||||||
|
@ -207,6 +207,7 @@ type listAllFn func(*drive.File) bool
|
||||||
// Search params: https://developers.google.com/drive/search-parameters
|
// Search params: https://developers.google.com/drive/search-parameters
|
||||||
func (f *Fs) listAll(dirID string, title string, directoriesOnly bool, filesOnly bool, includeTrashed bool, fn listAllFn) (found bool, err error) {
|
func (f *Fs) listAll(dirID string, title string, directoriesOnly bool, filesOnly bool, includeTrashed bool, fn listAllFn) (found bool, err error) {
|
||||||
var query []string
|
var query []string
|
||||||
|
|
||||||
if !includeTrashed {
|
if !includeTrashed {
|
||||||
query = append(query, "trashed=false")
|
query = append(query, "trashed=false")
|
||||||
}
|
}
|
||||||
|
@ -239,11 +240,19 @@ func (f *Fs) listAll(dirID string, title string, directoriesOnly bool, filesOnly
|
||||||
if *driveListChunk > 0 {
|
if *driveListChunk > 0 {
|
||||||
list = list.MaxResults(*driveListChunk)
|
list = list.MaxResults(*driveListChunk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var fields googleapi.Field
|
||||||
|
|
||||||
|
if *driveAuthOwnerOnly {
|
||||||
|
fields = googleapi.Field(fmt.Sprintf(partialFields, ",owners"))
|
||||||
|
} else {
|
||||||
|
fields = googleapi.Field(fmt.Sprintf(partialFields, ""))
|
||||||
|
}
|
||||||
OUTER:
|
OUTER:
|
||||||
for {
|
for {
|
||||||
var files *drive.FileList
|
var files *drive.FileList
|
||||||
err = f.pacer.Call(func() (bool, error) {
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
files, err = list.Fields(partialFields).Do()
|
files, err = list.Fields(fields).Do()
|
||||||
return shouldRetry(err)
|
return shouldRetry(err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue