(ctx context.Context, path string, objs []model.Obj)
| 22 | var strmTrie = patricia.NewTrie() |
| 23 | |
| 24 | func 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 | |
| 51 | func InsertStrm(dstPath string, d *Strm) error { |
| 52 | prefix := patricia.Prefix(strings.TrimRight(dstPath, "/")) |
nothing calls this directly
no test coverage detected