mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
jottacloud: improved error handling with SetModTime and corrupt files in general
This commit is contained in:
parent
159229527d
commit
b0f06d9920
@ -807,8 +807,17 @@ func (f *Fs) newObjectWithInfo(ctx context.Context, remote string, info *api.Jot
|
|||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
if info != nil {
|
if info != nil {
|
||||||
// Set info
|
if info.State != "COMPLETED" {
|
||||||
err = o.setMetaData(info)
|
return nil, fs.ErrorObjectNotFound // File is incomplete or corrupt
|
||||||
|
}
|
||||||
|
if o.fs.opt.TrashedOnly {
|
||||||
|
if !info.Deleted {
|
||||||
|
return nil, fs.ErrorObjectNotFound // Regular file but TrashedOnly
|
||||||
|
}
|
||||||
|
} else if bool(info.Deleted) {
|
||||||
|
return nil, fs.ErrorObjectNotFound // Deleted file and not TrashedOnly
|
||||||
|
}
|
||||||
|
err = o.setMetaData(info) // sets the info
|
||||||
} else {
|
} else {
|
||||||
err = o.readMetaData(ctx, false) // reads info and meta, returning an error
|
err = o.readMetaData(ctx, false) // reads info and meta, returning an error
|
||||||
}
|
}
|
||||||
@ -1385,8 +1394,15 @@ func (o *Object) readMetaData(ctx context.Context, force bool) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if bool(info.Deleted) && !o.fs.opt.TrashedOnly {
|
if info.State != "COMPLETED" {
|
||||||
return fs.ErrorObjectNotFound
|
return fs.ErrorObjectNotFound // File is incomplete or corrupt
|
||||||
|
}
|
||||||
|
if o.fs.opt.TrashedOnly {
|
||||||
|
if !info.Deleted {
|
||||||
|
return fs.ErrorObjectNotFound // Regular file but TrashedOnly
|
||||||
|
}
|
||||||
|
} else if bool(info.Deleted) {
|
||||||
|
return fs.ErrorObjectNotFound // Deleted file and not TrashedOnly
|
||||||
}
|
}
|
||||||
return o.setMetaData(info)
|
return o.setMetaData(info)
|
||||||
}
|
}
|
||||||
@ -1432,14 +1448,21 @@ func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// send it
|
// send it
|
||||||
|
var response api.AllocateFileResponse
|
||||||
err = o.fs.pacer.Call(func() (bool, error) {
|
err = o.fs.pacer.Call(func() (bool, error) {
|
||||||
resp, err = o.fs.apiSrv.CallJSON(ctx, &opts, &request, nil)
|
resp, err = o.fs.apiSrv.CallJSON(ctx, &opts, &request, &response)
|
||||||
return shouldRetry(ctx, resp, err)
|
return shouldRetry(ctx, resp, err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check response
|
||||||
|
if response.State != "COMPLETED" {
|
||||||
|
// could be the file was modified (size/md5 changed) between readMetaData and the allocate request
|
||||||
|
return errors.New("metadata did not match")
|
||||||
|
}
|
||||||
|
|
||||||
// update local metadata
|
// update local metadata
|
||||||
o.modTime = modTime
|
o.modTime = modTime
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user