mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-02-02 21:27:15 +08:00
support webdav rename action
This commit is contained in:
parent
5a88effab9
commit
d867267756
@ -146,4 +146,25 @@ func (p *PanClientProxy) Mkdir(pathStr string, perm os.FileMode) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("unknown error")
|
return fmt.Errorf("unknown error")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PanClientProxy) Rename(oldpath, newpath string) error {
|
||||||
|
oldFile, er := p.cacheFilePath(oldpath)
|
||||||
|
if er != nil {
|
||||||
|
return os.ErrNotExist
|
||||||
|
}
|
||||||
|
_,e := p.PanUser.PanClient().FileRename(p.PanDriveId, oldFile.FileId, path.Base(newpath))
|
||||||
|
if e != nil {
|
||||||
|
return os.ErrInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
// invalidate parent folder cache
|
||||||
|
p.deleteOneFilesDirectoriesListCache(path.Dir(oldpath))
|
||||||
|
|
||||||
|
// add new name cache
|
||||||
|
oldFile.Path = newpath
|
||||||
|
oldFile.FileName = path.Base(newpath)
|
||||||
|
p.cacheFilePathEntity(oldFile)
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
@ -126,7 +126,7 @@ 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 os.Rename(oldName, newName)
|
return d.panClientProxy.Rename(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) {
|
||||||
@ -135,7 +135,7 @@ func (d WebDavDir) Stat(ctx context.Context, name string) (os.FileInfo, error) {
|
|||||||
fileItem,e := d.panClientProxy.FileInfoByPath(d.formatAbsoluteName(name))
|
fileItem,e := d.panClientProxy.FileInfoByPath(d.formatAbsoluteName(name))
|
||||||
if e != nil {
|
if e != nil {
|
||||||
logger.Verboseln("file path not existed: " + d.formatAbsoluteName(name))
|
logger.Verboseln("file path not existed: " + d.formatAbsoluteName(name))
|
||||||
return nil, e
|
return nil, os.ErrNotExist
|
||||||
}
|
}
|
||||||
*f = NewWebDavFileInfo(fileItem)
|
*f = NewWebDavFileInfo(fileItem)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user