Add support for server side move operations
Depends on pull request at https://github.com/ncw/go-acd/pull/1
This commit is contained in:
parent
4105da206a
commit
ca017980a3
1 changed files with 46 additions and 1 deletions
|
@ -674,6 +674,51 @@ func (f *Fs) Hashes() fs.HashSet {
|
||||||
return fs.HashSet(fs.HashMD5)
|
return fs.HashSet(fs.HashMD5)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
|
||||||
|
srcObj, ok := src.(*Object)
|
||||||
|
if !ok {
|
||||||
|
fs.Debug(src, "Can't move - not same remote type")
|
||||||
|
return nil, fs.ErrorCantMove
|
||||||
|
}
|
||||||
|
|
||||||
|
// Temporary Object under construction
|
||||||
|
dstObj := &Object{
|
||||||
|
fs: f,
|
||||||
|
remote: remote,
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
_, directoryID, err := f.dirCache.FindPath(remote, false)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var info *acd.Node
|
||||||
|
var resp *http.Response
|
||||||
|
if directoryID == srcObj.info.Parents[0] {
|
||||||
|
// Do the rename
|
||||||
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
|
info, resp, err = srcObj.info.Rename(remote)
|
||||||
|
return srcObj.fs.shouldRetry(resp, err)
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Do the move
|
||||||
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
|
info, resp, err = srcObj.info.Move(directoryID)
|
||||||
|
return srcObj.fs.shouldRetry(resp, err)
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dstObj.info = info
|
||||||
|
return dstObj, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Copy src to this remote using server side copy operations.
|
// Copy src to this remote using server side copy operations.
|
||||||
//
|
//
|
||||||
// This is stored with the remote path given
|
// This is stored with the remote path given
|
||||||
|
@ -881,7 +926,7 @@ var (
|
||||||
_ fs.Fs = (*Fs)(nil)
|
_ fs.Fs = (*Fs)(nil)
|
||||||
_ fs.Purger = (*Fs)(nil)
|
_ fs.Purger = (*Fs)(nil)
|
||||||
// _ fs.Copier = (*Fs)(nil)
|
// _ fs.Copier = (*Fs)(nil)
|
||||||
// _ fs.Mover = (*Fs)(nil)
|
_ fs.Mover = (*Fs)(nil)
|
||||||
// _ fs.DirMover = (*Fs)(nil)
|
// _ fs.DirMover = (*Fs)(nil)
|
||||||
_ fs.Object = (*Object)(nil)
|
_ fs.Object = (*Object)(nil)
|
||||||
_ fs.MimeTyper = &Object{}
|
_ fs.MimeTyper = &Object{}
|
||||||
|
|
Loading…
Add table
Reference in a new issue