mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-02-10 03:34:39 +08:00
add webdav move file action
This commit is contained in:
parent
d867267756
commit
a4a74f062e
@ -168,3 +168,35 @@ func (p *PanClientProxy) Rename(oldpath, newpath string) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (p *PanClientProxy) Move(oldpath, newpath string) error {
|
||||||
|
oldFile, er := p.cacheFilePath(oldpath)
|
||||||
|
if er != nil {
|
||||||
|
return os.ErrNotExist
|
||||||
|
}
|
||||||
|
|
||||||
|
newFileParentDir,er := p.cacheFilePath(path.Dir(newpath))
|
||||||
|
if er != nil {
|
||||||
|
return os.ErrNotExist
|
||||||
|
}
|
||||||
|
|
||||||
|
param := aliyunpan.FileMoveParam{
|
||||||
|
DriveId: p.PanDriveId,
|
||||||
|
FileId: oldFile.FileId,
|
||||||
|
ToDriveId: p.PanDriveId,
|
||||||
|
ToParentFileId: newFileParentDir.FileId,
|
||||||
|
}
|
||||||
|
params := []*aliyunpan.FileMoveParam{}
|
||||||
|
params = append(params, ¶m)
|
||||||
|
_,e := p.PanUser.PanClient().FileMove(params)
|
||||||
|
if e != nil {
|
||||||
|
return os.ErrInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
// invalidate parent folder cache
|
||||||
|
p.deleteOneFilesDirectoriesListCache(path.Dir(oldpath))
|
||||||
|
p.deleteOneFilesDirectoriesListCache(path.Dir(newpath))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
@ -126,7 +126,13 @@ func (d WebDavDir) Rename(ctx context.Context, oldName, newName string) error {
|
|||||||
// Prohibit renaming from or to the virtual root directory.
|
// Prohibit renaming from or to the virtual root directory.
|
||||||
return os.ErrInvalid
|
return os.ErrInvalid
|
||||||
}
|
}
|
||||||
return d.panClientProxy.Rename(oldName, newName)
|
if path.Dir(oldName) == path.Dir(newName) {
|
||||||
|
// rename
|
||||||
|
return d.panClientProxy.Rename(oldName, newName)
|
||||||
|
} else {
|
||||||
|
// move file
|
||||||
|
return d.panClientProxy.Move(oldName, newName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d WebDavDir) Stat(ctx context.Context, name string) (os.FileInfo, error) {
|
func (d WebDavDir) Stat(ctx context.Context, name string) (os.FileInfo, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user