(ctx context.Context, srcObj, dstDir model.Obj)
| 290 | } |
| 291 | |
| 292 | func (d *Local) Move(ctx context.Context, srcObj, dstDir model.Obj) error { |
| 293 | srcPath := srcObj.GetPath() |
| 294 | dstPath := filepath.Join(dstDir.GetPath(), srcObj.GetName()) |
| 295 | if utils.IsSubPath(srcPath, dstPath) { |
| 296 | return fmt.Errorf("the destination folder is a subfolder of the source folder") |
| 297 | } |
| 298 | err := os.Rename(srcPath, dstPath) |
| 299 | if isCrossDeviceError(err) { |
| 300 | // 跨设备移动,变更为移动任务 |
| 301 | return errs.NotImplement |
| 302 | } |
| 303 | if err == nil { |
| 304 | srcParent := filepath.Dir(srcPath) |
| 305 | dstParent := filepath.Dir(dstPath) |
| 306 | if d.directoryMap.Has(srcParent) { |
| 307 | d.directoryMap.UpdateDirSize(srcParent) |
| 308 | d.directoryMap.UpdateDirParents(srcParent) |
| 309 | } |
| 310 | if d.directoryMap.Has(dstParent) { |
| 311 | d.directoryMap.UpdateDirSize(dstParent) |
| 312 | d.directoryMap.UpdateDirParents(dstParent) |
| 313 | } |
| 314 | } |
| 315 | return err |
| 316 | } |
| 317 | |
| 318 | func (d *Local) Rename(ctx context.Context, srcObj model.Obj, newName string) error { |
| 319 | srcPath := srcObj.GetPath() |
nothing calls this directly
no test coverage detected