MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / Move

Method Move

drivers/local/driver.go:292–316  ·  view source on GitHub ↗
(ctx context.Context, srcObj, dstDir model.Obj)

Source from the content-addressed store, hash-verified

290}
291
292func (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
318func (d *Local) Rename(ctx context.Context, srcObj model.Obj, newName string) error {
319 srcPath := srcObj.GetPath()

Callers

nothing calls this directly

Calls 8

IsSubPathFunction · 0.92
UpdateDirSizeMethod · 0.80
UpdateDirParentsMethod · 0.80
isCrossDeviceErrorFunction · 0.70
GetPathMethod · 0.65
GetNameMethod · 0.65
RenameMethod · 0.65
HasMethod · 0.45

Tested by

no test coverage detected