Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

pikpak: fix error with `copyto` command

wiserain65077700141b
diff --git a/backend/pikpak/pikpak.go b/backend/pikpak/pikpak.go
index 5fca36658..2095a391d 100644
--- a/backend/pikpak/pikpak.go
+++ b/backend/pikpak/pikpak.go
@@ -1016,6 +1016,7 @@ func (f *Fs) createObject(ctx context.Context, remote string, modTime time.Time,
o = &Object{
fs: f,
remote: remote,
+ parent: dirID,
size: size,
modTime: modTime,
linkMu: new(sync.Mutex),
@@ -1117,7 +1118,7 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
return nil, err
}
- // Create temporary object
+ // Create temporary object - still missing id, mimeType, gcid, md5sum
dstObj, dstLeaf, dstParentID, err := f.createObject(ctx, remote, srcObj.modTime, srcObj.size)
if err != nil {
return nil, err
@@ -1131,6 +1132,12 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
if err := f.copyObjects(ctx, []string{srcObj.id}, dstParentID); err != nil {
return nil, fmt.Errorf("couldn't copy file: %w", err)
}
+ // Update info of the copied object with new parent but source name
+ if info, err := dstObj.fs.readMetaDataForPath(ctx, srcObj.remote); err != nil {
+ return nil, fmt.Errorf("copy: couldn't locate copied file: %w", err)
+ } else if err = dstObj.setMetaData(info); err != nil {
+ return nil, err
+ }
// Can't copy and change name in one step so we have to check if we have
// the correct name after copy
@@ -1145,16 +1152,7 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
if err != nil {
return nil, fmt.Errorf("copy: couldn't rename copied file: %w", err)
}
- err = dstObj.setMetaData(info)
- if err != nil {
- return nil, err
- }
- } else {
- // Update info
- err = dstObj.readMetaData(ctx)
- if err != nil {
- return nil, fmt.Errorf("copy: couldn't locate copied file: %w", err)
- }
+ return dstObj, dstObj.setMetaData(info)
}
return dstObj, nil
}