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

Function UpdateLocalStrm

drivers/strm/hook.go:24–49  ·  view source on GitHub ↗
(ctx context.Context, path string, objs []model.Obj)

Source from the content-addressed store, hash-verified

22var strmTrie = patricia.NewTrie()
23
24func UpdateLocalStrm(ctx context.Context, path string, objs []model.Obj) {
25 path = utils.FixAndCleanPath(path)
26 updateLocal := func(driver *Strm, basePath string, objs []model.Obj) {
27 relParent := strings.TrimPrefix(basePath, utils.GetActualMountPath(driver.MountPath))
28 localParentPath := stdpath.Join(driver.SaveStrmLocalPath, relParent)
29 for _, obj := range objs {
30 localPath := stdpath.Join(localParentPath, obj.GetName())
31 generateStrm(ctx, driver, obj, localPath)
32 }
33 deleteExtraFiles(driver, localParentPath, objs)
34 }
35
36 _ = strmTrie.VisitPrefixes(patricia.Prefix(path), func(needPathPrefix patricia.Prefix, item patricia.Item) error {
37 strmDrivers := item.([]*Strm)
38 needPath := string(needPathPrefix)
39 restPath := strings.TrimPrefix(path, needPath)
40 if len(restPath) > 0 && restPath[0] != '/' {
41 return nil
42 }
43 for _, strmDriver := range strmDrivers {
44 strmObjs := strmDriver.convert2strmObjs(ctx, path, objs)
45 updateLocal(strmDriver, stdpath.Join(stdpath.Base(needPath), restPath), strmObjs)
46 }
47 return nil
48 })
49}
50
51func InsertStrm(dstPath string, d *Strm) error {
52 prefix := patricia.Prefix(strings.TrimRight(dstPath, "/"))

Callers

nothing calls this directly

Calls 6

FixAndCleanPathFunction · 0.92
GetActualMountPathFunction · 0.92
generateStrmFunction · 0.85
deleteExtraFilesFunction · 0.85
convert2strmObjsMethod · 0.80
GetNameMethod · 0.65

Tested by

no test coverage detected