mirror of
https://github.com/rclone/rclone.git
synced 2024-12-25 00:19:13 +01:00
crypt: Implement DirMover
This commit is contained in:
parent
a54806e5c1
commit
73cd1f4e88
@ -99,7 +99,7 @@ type Fs struct {
|
|||||||
|
|
||||||
// String returns a description of the FS
|
// String returns a description of the FS
|
||||||
func (f *Fs) String() string {
|
func (f *Fs) String() string {
|
||||||
return fmt.Sprintf("%s with cipher", f.Fs.String())
|
return fmt.Sprintf("Encrypted %s", f.Fs.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// List the Fs into a channel
|
// List the Fs into a channel
|
||||||
@ -193,7 +193,7 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
|
|||||||
}
|
}
|
||||||
o, ok := src.(*Object)
|
o, ok := src.(*Object)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fs.ErrorCantCopy
|
return nil, fs.ErrorCantMove
|
||||||
}
|
}
|
||||||
oResult, err := do.Move(o.Object, f.cipher.EncryptFileName(remote))
|
oResult, err := do.Move(o.Object, f.cipher.EncryptFileName(remote))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -202,6 +202,27 @@ func (f *Fs) Move(src fs.Object, remote string) (fs.Object, error) {
|
|||||||
return f.newObject(oResult), nil
|
return f.newObject(oResult), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DirMove moves src to this remote using server side move
|
||||||
|
// operations.
|
||||||
|
//
|
||||||
|
// Will only be called if src.Fs().Name() == f.Name()
|
||||||
|
//
|
||||||
|
// If it isn't possible then return fs.ErrorCantDirMove
|
||||||
|
//
|
||||||
|
// If destination exists then return fs.ErrorDirExists
|
||||||
|
func (f *Fs) DirMove(src fs.Fs) error {
|
||||||
|
do, ok := f.Fs.(fs.DirMover)
|
||||||
|
if !ok {
|
||||||
|
return fs.ErrorCantDirMove
|
||||||
|
}
|
||||||
|
srcFs, ok := src.(*Fs)
|
||||||
|
if !ok {
|
||||||
|
fs.Debug(srcFs, "Can't move directory - not same remote type")
|
||||||
|
return fs.ErrorCantDirMove
|
||||||
|
}
|
||||||
|
return do.DirMove(srcFs.Fs)
|
||||||
|
}
|
||||||
|
|
||||||
// UnWrap returns the Fs that this Fs is wrapping
|
// UnWrap returns the Fs that this Fs is wrapping
|
||||||
func (f *Fs) UnWrap() fs.Fs {
|
func (f *Fs) UnWrap() fs.Fs {
|
||||||
return f.Fs
|
return f.Fs
|
||||||
@ -396,11 +417,11 @@ func (lo *ListOpts) IncludeDirectory(remote string) bool {
|
|||||||
|
|
||||||
// Check the interfaces are satisfied
|
// Check the interfaces are satisfied
|
||||||
var (
|
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.PutUncheckeder = (*Fs)(nil)
|
// _ fs.PutUncheckeder = (*Fs)(nil)
|
||||||
_ fs.UnWrapper = (*Fs)(nil)
|
_ fs.UnWrapper = (*Fs)(nil)
|
||||||
_ fs.ObjectInfo = (*ObjectInfo)(nil)
|
_ fs.ObjectInfo = (*ObjectInfo)(nil)
|
||||||
|
Loading…
Reference in New Issue
Block a user