mirror of
https://github.com/rclone/rclone.git
synced 2025-02-03 12:09:44 +01:00
opendrive: resolve lag and truncate bugs fixes #5936
Co-authored-by: buengese <buengese@protonmail.com>
This commit is contained in:
parent
dcc128c70d
commit
295006f662
@ -362,7 +362,7 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
|||||||
srcPath := srcObj.fs.rootSlash() + srcObj.remote
|
srcPath := srcObj.fs.rootSlash() + srcObj.remote
|
||||||
dstPath := f.rootSlash() + remote
|
dstPath := f.rootSlash() + remote
|
||||||
if strings.EqualFold(srcPath, dstPath) {
|
if strings.EqualFold(srcPath, dstPath) {
|
||||||
return nil, fmt.Errorf("Can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
|
return nil, fmt.Errorf("can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create temporary object
|
// Create temporary object
|
||||||
@ -429,6 +429,12 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// move_copy will silently truncate new filenames
|
||||||
|
if len(leaf) > 255 {
|
||||||
|
fs.Debugf(src, "Can't move file: name (%q) exceeds 255 char", leaf)
|
||||||
|
return nil, fs.ErrorFileNameTooLong
|
||||||
|
}
|
||||||
|
|
||||||
// Copy the object
|
// Copy the object
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
response := moveCopyFileResponse{}
|
response := moveCopyFileResponse{}
|
||||||
@ -1024,30 +1030,52 @@ func (o *Object) readMetaData(ctx context.Context) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
folderList := FolderList{}
|
fileInfo := File{}
|
||||||
err = o.fs.pacer.Call(func() (bool, error) {
|
|
||||||
|
// If we know the object id perform a direct lookup
|
||||||
|
// because the /folder/itembyname.json endpoint is unreliable:
|
||||||
|
// newly created objects take an arbitrary amount of time to show up
|
||||||
|
if o.id != "" {
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
Path: fmt.Sprintf("/folder/itembyname.json/%s/%s?name=%s",
|
Path: fmt.Sprintf("/file/info.json/%s?session_id=%s",
|
||||||
o.fs.session.SessionID, directoryID, url.QueryEscape(o.fs.opt.Enc.FromStandardName(leaf))),
|
o.id, o.fs.session.SessionID),
|
||||||
}
|
}
|
||||||
|
err = o.fs.pacer.Call(func() (bool, error) {
|
||||||
|
resp, err = o.fs.srv.CallJSON(ctx, &opts, nil, &fileInfo)
|
||||||
|
return o.fs.shouldRetry(ctx, resp, err)
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to get fileinfo: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
o.id = fileInfo.FileID
|
||||||
|
o.modTime = time.Unix(fileInfo.DateModified, 0)
|
||||||
|
o.md5 = fileInfo.FileHash
|
||||||
|
o.size = fileInfo.Size
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
folderList := FolderList{}
|
||||||
|
opts := rest.Opts{
|
||||||
|
Method: "GET",
|
||||||
|
Path: fmt.Sprintf("/folder/itembyname.json/%s/%s?name=%s",
|
||||||
|
o.fs.session.SessionID, directoryID, url.QueryEscape(o.fs.opt.Enc.FromStandardName(leaf))),
|
||||||
|
}
|
||||||
|
err = o.fs.pacer.Call(func() (bool, error) {
|
||||||
resp, err = o.fs.srv.CallJSON(ctx, &opts, nil, &folderList)
|
resp, err = o.fs.srv.CallJSON(ctx, &opts, nil, &folderList)
|
||||||
return o.fs.shouldRetry(ctx, resp, err)
|
return o.fs.shouldRetry(ctx, resp, err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get folder list: %w", err)
|
return fmt.Errorf("failed to get folder list: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(folderList.Files) == 0 {
|
if len(folderList.Files) == 0 {
|
||||||
return fs.ErrorObjectNotFound
|
return fs.ErrorObjectNotFound
|
||||||
}
|
}
|
||||||
|
fileInfo = folderList.Files[0]
|
||||||
leafFile := folderList.Files[0]
|
o.id = fileInfo.FileID
|
||||||
o.id = leafFile.FileID
|
o.modTime = time.Unix(fileInfo.DateModified, 0)
|
||||||
o.modTime = time.Unix(leafFile.DateModified, 0)
|
o.md5 = fileInfo.FileHash
|
||||||
o.md5 = leafFile.FileHash
|
o.size = fileInfo.Size
|
||||||
o.size = leafFile.Size
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user