mirror of
https://github.com/rclone/rclone.git
synced 2024-11-29 11:55:01 +01:00
drive: use explicit fields for all endpoints
Reuses the same fields for all endpoints for simplicitys sake. Should solve remaining part of #1346
This commit is contained in:
parent
b6517840ca
commit
56f017c60c
@ -84,7 +84,7 @@ var (
|
|||||||
"text/tab-separated-values": "tsv",
|
"text/tab-separated-values": "tsv",
|
||||||
}
|
}
|
||||||
extensionToMimeType map[string]string
|
extensionToMimeType map[string]string
|
||||||
partialFields = "items(id,downloadUrl,exportLinks,fileExtension,fullFileExtension,fileSize,labels,md5Checksum,modifiedDate,mimeType,title%s),nextPageToken"
|
partialFields = "id,downloadUrl,exportLinks,fileExtension,fullFileExtension,fileSize,labels,md5Checksum,modifiedDate,mimeType,title"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register with Fs
|
// Register with Fs
|
||||||
@ -241,18 +241,19 @@ func (f *Fs) listAll(dirID string, title string, directoriesOnly bool, filesOnly
|
|||||||
list = list.MaxResults(*driveListChunk)
|
list = list.MaxResults(*driveListChunk)
|
||||||
}
|
}
|
||||||
|
|
||||||
var fields googleapi.Field
|
var fields = partialFields
|
||||||
|
|
||||||
if *driveAuthOwnerOnly {
|
if *driveAuthOwnerOnly {
|
||||||
fields = googleapi.Field(fmt.Sprintf(partialFields, ",owners"))
|
fields += ",owners"
|
||||||
} else {
|
|
||||||
fields = googleapi.Field(fmt.Sprintf(partialFields, ""))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fields = fmt.Sprintf("items(%s),nextPageToken", fields)
|
||||||
|
|
||||||
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(fields).Do()
|
files, err = list.Fields(googleapi.Field(fields)).Do()
|
||||||
return shouldRetry(err)
|
return shouldRetry(err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -435,7 +436,7 @@ func (f *Fs) CreateDir(pathID, leaf string) (newID string, err error) {
|
|||||||
}
|
}
|
||||||
var info *drive.File
|
var info *drive.File
|
||||||
err = f.pacer.Call(func() (bool, error) {
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
info, err = f.svc.Files.Insert(createInfo).Do()
|
info, err = f.svc.Files.Insert(createInfo).Fields(googleapi.Field(partialFields)).Do()
|
||||||
return shouldRetry(err)
|
return shouldRetry(err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -614,7 +615,7 @@ func (f *Fs) PutUnchecked(in io.Reader, src fs.ObjectInfo) (fs.Object, error) {
|
|||||||
// Make the API request to upload metadata and file data.
|
// Make the API request to upload metadata and file data.
|
||||||
// Don't retry, return a retry error instead
|
// Don't retry, return a retry error instead
|
||||||
err = f.pacer.CallNoRetry(func() (bool, error) {
|
err = f.pacer.CallNoRetry(func() (bool, error) {
|
||||||
info, err = f.svc.Files.Insert(createInfo).Media(in, googleapi.ContentType("")).Do()
|
info, err = f.svc.Files.Insert(createInfo).Media(in, googleapi.ContentType("")).Fields(googleapi.Field(partialFields)).Do()
|
||||||
return shouldRetry(err)
|
return shouldRetry(err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -676,9 +677,9 @@ func (f *Fs) Rmdir(dir string) error {
|
|||||||
// in or the user wants to trash, otherwise
|
// in or the user wants to trash, otherwise
|
||||||
// delete it.
|
// delete it.
|
||||||
if trashedFiles || *driveUseTrash {
|
if trashedFiles || *driveUseTrash {
|
||||||
_, err = f.svc.Files.Trash(directoryID).Do()
|
_, err = f.svc.Files.Trash(directoryID).Fields(googleapi.Field(partialFields)).Do()
|
||||||
} else {
|
} else {
|
||||||
err = f.svc.Files.Delete(directoryID).Do()
|
err = f.svc.Files.Delete(directoryID).Fields(googleapi.Field(partialFields)).Do()
|
||||||
}
|
}
|
||||||
return shouldRetry(err)
|
return shouldRetry(err)
|
||||||
})
|
})
|
||||||
@ -724,7 +725,7 @@ func (f *Fs) Copy(src fs.Object, remote string) (fs.Object, error) {
|
|||||||
|
|
||||||
var info *drive.File
|
var info *drive.File
|
||||||
err = o.fs.pacer.Call(func() (bool, error) {
|
err = o.fs.pacer.Call(func() (bool, error) {
|
||||||
info, err = o.fs.svc.Files.Copy(srcObj.id, createInfo).Do()
|
info, err = o.fs.svc.Files.Copy(srcObj.id, createInfo).Fields(googleapi.Field(partialFields)).Do()
|
||||||
return shouldRetry(err)
|
return shouldRetry(err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -750,9 +751,9 @@ func (f *Fs) Purge() error {
|
|||||||
}
|
}
|
||||||
err = f.pacer.Call(func() (bool, error) {
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
if *driveUseTrash {
|
if *driveUseTrash {
|
||||||
_, err = f.svc.Files.Trash(f.dirCache.RootID()).Do()
|
_, err = f.svc.Files.Trash(f.dirCache.RootID()).Fields(googleapi.Field(partialFields)).Do()
|
||||||
} else {
|
} else {
|
||||||
err = f.svc.Files.Delete(f.dirCache.RootID()).Do()
|
err = f.svc.Files.Delete(f.dirCache.RootID()).Fields(googleapi.Field(partialFields)).Do()
|
||||||
}
|
}
|
||||||
return shouldRetry(err)
|
return shouldRetry(err)
|
||||||
})
|
})
|
||||||
@ -791,7 +792,7 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
|
|||||||
// Do the move
|
// Do the move
|
||||||
var info *drive.File
|
var info *drive.File
|
||||||
err = f.pacer.Call(func() (bool, error) {
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
info, err = f.svc.Files.Patch(srcObj.id, dstInfo).SetModifiedDate(true).Do()
|
info, err = f.svc.Files.Patch(srcObj.id, dstInfo).SetModifiedDate(true).Fields(googleapi.Field(partialFields)).Do()
|
||||||
return shouldRetry(err)
|
return shouldRetry(err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -878,7 +879,7 @@ func (f *Fs) DirMove(src fs.Fs, srcRemote, dstRemote string) error {
|
|||||||
Parents: []*drive.ParentReference{{Id: directoryID}},
|
Parents: []*drive.ParentReference{{Id: directoryID}},
|
||||||
}
|
}
|
||||||
err = f.pacer.Call(func() (bool, error) {
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
_, err = f.svc.Files.Patch(srcID, &patch).Do()
|
_, err = f.svc.Files.Patch(srcID, &patch).Fields(googleapi.Field(partialFields)).Do()
|
||||||
return shouldRetry(err)
|
return shouldRetry(err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1016,7 +1017,7 @@ func (o *Object) SetModTime(modTime time.Time) error {
|
|||||||
// Set modified date
|
// Set modified date
|
||||||
var info *drive.File
|
var info *drive.File
|
||||||
err = o.fs.pacer.Call(func() (bool, error) {
|
err = o.fs.pacer.Call(func() (bool, error) {
|
||||||
info, err = o.fs.svc.Files.Update(o.id, updateInfo).SetModifiedDate(true).Do()
|
info, err = o.fs.svc.Files.Update(o.id, updateInfo).SetModifiedDate(true).Fields(googleapi.Field(partialFields)).Do()
|
||||||
return shouldRetry(err)
|
return shouldRetry(err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1128,7 +1129,7 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo) error {
|
|||||||
if size == 0 || size < int64(driveUploadCutoff) {
|
if size == 0 || size < int64(driveUploadCutoff) {
|
||||||
// Don't retry, return a retry error instead
|
// Don't retry, return a retry error instead
|
||||||
err = o.fs.pacer.CallNoRetry(func() (bool, error) {
|
err = o.fs.pacer.CallNoRetry(func() (bool, error) {
|
||||||
info, err = o.fs.svc.Files.Update(updateInfo.Id, updateInfo).SetModifiedDate(true).Media(in, googleapi.ContentType("")).Do()
|
info, err = o.fs.svc.Files.Update(updateInfo.Id, updateInfo).SetModifiedDate(true).Media(in, googleapi.ContentType("")).Fields(googleapi.Field(partialFields)).Do()
|
||||||
return shouldRetry(err)
|
return shouldRetry(err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1153,9 +1154,9 @@ func (o *Object) Remove() error {
|
|||||||
var err error
|
var err error
|
||||||
err = o.fs.pacer.Call(func() (bool, error) {
|
err = o.fs.pacer.Call(func() (bool, error) {
|
||||||
if *driveUseTrash {
|
if *driveUseTrash {
|
||||||
_, err = o.fs.svc.Files.Trash(o.id).Do()
|
_, err = o.fs.svc.Files.Trash(o.id).Fields(googleapi.Field(partialFields)).Do()
|
||||||
} else {
|
} else {
|
||||||
err = o.fs.svc.Files.Delete(o.id).Do()
|
err = o.fs.svc.Files.Delete(o.id).Fields(googleapi.Field(partialFields)).Do()
|
||||||
}
|
}
|
||||||
return shouldRetry(err)
|
return shouldRetry(err)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user