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

Method Copy

drivers/local/driver.go:336–357  ·  view source on GitHub ↗
(_ context.Context, srcObj, dstDir model.Obj)

Source from the content-addressed store, hash-verified

334}
335
336func (d *Local) Copy(_ context.Context, srcObj, dstDir model.Obj) error {
337 srcPath := srcObj.GetPath()
338 dstPath := filepath.Join(dstDir.GetPath(), srcObj.GetName())
339 if utils.IsSubPath(srcPath, dstPath) {
340 return fmt.Errorf("the destination folder is a subfolder of the source folder")
341 }
342 info, err := os.Lstat(srcPath)
343 if err != nil {
344 return err
345 }
346 // 复制regular文件会返回errs.NotImplement, 转为复制任务
347 if err = d.tryCopy(srcPath, dstPath, info); err != nil {
348 return err
349 }
350
351 if d.directoryMap.Has(filepath.Dir(dstPath)) {
352 d.directoryMap.UpdateDirSize(filepath.Dir(dstPath))
353 d.directoryMap.UpdateDirParents(filepath.Dir(dstPath))
354 }
355
356 return nil
357}
358
359func (d *Local) Remove(ctx context.Context, obj model.Obj) error {
360 var err error

Callers

nothing calls this directly

Calls 7

tryCopyMethod · 0.95
IsSubPathFunction · 0.92
UpdateDirSizeMethod · 0.80
UpdateDirParentsMethod · 0.80
GetPathMethod · 0.65
GetNameMethod · 0.65
HasMethod · 0.45

Tested by

no test coverage detected