"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
pikpak: improve getFile() usage
wiserainb2f6aac754c5
diff --git a/backend/pikpak/api/types.go b/backend/pikpak/api/types.goindex 92c81d426..8b2270e2a 100644--- a/backend/pikpak/api/types.go+++ b/backend/pikpak/api/types.go@@ -53,7 +53,7 @@ const (PhaseTypePending = "PHASE_TYPE_PENDING"UploadTypeForm = "UPLOAD_TYPE_FORM"UploadTypeResumable = "UPLOAD_TYPE_RESUMABLE"- ListLimit = 100+ ListLimit = 500)// ------------------------------------------------------------@@ -156,6 +156,7 @@ type FileList struct {NextPageToken string `json:"next_page_token"`Version string `json:"version,omitempty"`VersionOutdated bool `json:"version_outdated,omitempty"`+ SyncTime Time `json:"sync_time"`}// File is a basic element representing a single file object@@ -165,14 +166,14 @@ type FileList struct {// 2) the other from File.Medias[].Link.URL.// Empirically, 2) is less restrictive to multiple concurrent range-requests// for a single file, i.e. supports for higher `--multi-thread-streams=N`.-// However, it is not generally applicable as it is only for meadia.+// However, it is not generally applicable as it is only for media.type File struct {Apps []*FileApp `json:"apps,omitempty"`Audit *FileAudit `json:"audit,omitempty"`Collection string `json:"collection,omitempty"` // TODOCreatedTime Time `json:"created_time,omitempty"`DeleteTime Time `json:"delete_time,omitempty"`- FileCategory string `json:"file_category,omitempty"`+ FileCategory string `json:"file_category,omitempty"` // "AUDIO", "VIDEO"FileExtension string `json:"file_extension,omitempty"`FolderType string `json:"folder_type,omitempty"`Hash string `json:"hash,omitempty"` // sha1 but NOT a valid file hash. looks like a torrent hash@@ -191,11 +192,14 @@ type File struct {ParentID string `json:"parent_id,omitempty"`Phase string `json:"phase,omitempty"`Revision int `json:"revision,omitempty,string"`+ ReferenceEvents []interface{} `json:"reference_events"`+ ReferenceResource interface{} `json:"reference_resource"`Size int64 `json:"size,omitempty,string"`SortName string `json:"sort_name,omitempty"`Space string `json:"space,omitempty"`SpellName []interface{} `json:"spell_name,omitempty"` // TODO maybe list of something?Starred bool `json:"starred,omitempty"`+ Tags []interface{} `json:"tags"`ThumbnailLink string `json:"thumbnail_link,omitempty"`Trashed bool `json:"trashed,omitempty"`UserID string `json:"user_id,omitempty"`@@ -241,7 +245,8 @@ type Media struct {IsOrigin bool `json:"is_origin,omitempty"`ResolutionName string `json:"resolution_name,omitempty"`IsVisible bool `json:"is_visible,omitempty"`- Category string `json:"category,omitempty"`+ Category string `json:"category,omitempty"` // "category_origin"+ Audio interface{} `json:"audio"` // TODO: undiscovered yet}// FileParams includes parameters for instant open@@ -395,6 +400,7 @@ type Quota struct {UsageInTrash int64 `json:"usage_in_trash,omitempty,string"` // bytes in trash but this seems not workingPlayTimesLimit string `json:"play_times_limit,omitempty"` // maybe in secondsPlayTimesUsage string `json:"play_times_usage,omitempty"` // maybe in seconds+ IsUnlimited bool `json:"is_unlimited,omitempty"`}// Share is a response to RequestSharediff --git a/backend/pikpak/pikpak.go b/backend/pikpak/pikpak.goindex 07fc0b201..008180356 100644--- a/backend/pikpak/pikpak.go+++ b/backend/pikpak/pikpak.go@@ -1016,21 +1016,24 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object,}dstObj.id = srcObj.id- var info *api.Fileif srcLeaf != dstLeaf {// Rename- info, err = f.renameObject(ctx, srcObj.id, dstLeaf)+ info, err := f.renameObject(ctx, srcObj.id, dstLeaf)if err != nil {return nil, fmt.Errorf("move: couldn't rename moved file: %w", err)}+ err = dstObj.setMetaData(info)+ if err != nil {+ return nil, err+ }} else {// Update info- info, err = f.getFile(ctx, dstObj.id)+ err = dstObj.readMetaData(ctx)if err != nil {- return nil, fmt.Errorf("move: couldn't update moved file: %w", err)+ return nil, fmt.Errorf("move: couldn't locate moved file: %w", err)}}- return dstObj, dstObj.setMetaData(info)+ return dstObj, nil}// copy objects@@ -1143,7 +1146,7 @@ func (f *Fs) uploadByForm(ctx context.Context, in io.Reader, name string, size ireturn}-func (f *Fs) uploadByResumable(ctx context.Context, in io.Reader, resumable *api.Resumable, options ...fs.OpenOption) (err error) {+func (f *Fs) uploadByResumable(ctx context.Context, in io.Reader, resumable *api.Resumable) (err error) {p := resumable.Paramsendpoint := strings.Join(strings.Split(p.Endpoint, ".")[1:], ".") // "mypikpak.com"@@ -1206,7 +1209,7 @@ func (f *Fs) upload(ctx context.Context, in io.Reader, leaf, dirID, sha1Str striif uploadType == api.UploadTypeForm && newfile.Form != nil {err = f.uploadByForm(ctx, in, req.Name, size, newfile.Form, options...)} else if uploadType == api.UploadTypeResumable && newfile.Resumable != nil {- err = f.uploadByResumable(ctx, in, newfile.Resumable, options...)+ err = f.uploadByResumable(ctx, in, newfile.Resumable)} else {return nil, fmt.Errorf("unable to proceed upload: %+v", newfile)}@@ -1214,10 +1217,7 @@ func (f *Fs) upload(ctx context.Context, in io.Reader, leaf, dirID, sha1Str striif err != nil {return nil, fmt.Errorf("failed to upload: %w", err)}- // refresh uploaded file info- // Compared to `newfile.File` this upgrades several fields...- // audit, links, modified_time, phase, revision, and web_content_link- return f.getFile(ctx, newfile.File.ID)+ return newfile.File, nil}// Put the object