|
@ -21,13 +21,15 @@ type MetaCache struct { |
|
|
sync.RWMutex |
|
|
sync.RWMutex |
|
|
visitedBoundary *bounded_tree.BoundedTree |
|
|
visitedBoundary *bounded_tree.BoundedTree |
|
|
uidGidMapper *UidGidMapper |
|
|
uidGidMapper *UidGidMapper |
|
|
|
|
|
invalidateFunc func(util.FullPath) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func NewMetaCache(dbFolder string, baseDir util.FullPath, uidGidMapper *UidGidMapper) *MetaCache { |
|
|
|
|
|
|
|
|
func NewMetaCache(dbFolder string, baseDir util.FullPath, uidGidMapper *UidGidMapper, invalidateFunc func(util.FullPath)) *MetaCache { |
|
|
return &MetaCache{ |
|
|
return &MetaCache{ |
|
|
localStore: openMetaStore(dbFolder), |
|
|
localStore: openMetaStore(dbFolder), |
|
|
visitedBoundary: bounded_tree.NewBoundedTree(baseDir), |
|
|
visitedBoundary: bounded_tree.NewBoundedTree(baseDir), |
|
|
uidGidMapper: uidGidMapper, |
|
|
uidGidMapper: uidGidMapper, |
|
|
|
|
|
invalidateFunc: invalidateFunc, |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -70,7 +72,7 @@ func (mc *MetaCache) AtomicUpdateEntryFromFiler(ctx context.Context, oldPath uti |
|
|
// skip the unnecessary deletion
|
|
|
// skip the unnecessary deletion
|
|
|
// leave the update to the following InsertEntry operation
|
|
|
// leave the update to the following InsertEntry operation
|
|
|
} else { |
|
|
} else { |
|
|
glog.V(3).Infof("DeleteEntry %s/%s", oldPath,oldPath.Name()) |
|
|
|
|
|
|
|
|
glog.V(3).Infof("DeleteEntry %s/%s", oldPath, oldPath.Name()) |
|
|
if err := mc.localStore.DeleteEntry(ctx, oldPath); err != nil { |
|
|
if err := mc.localStore.DeleteEntry(ctx, oldPath); err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
@ -83,7 +85,7 @@ func (mc *MetaCache) AtomicUpdateEntryFromFiler(ctx context.Context, oldPath uti |
|
|
if newEntry != nil { |
|
|
if newEntry != nil { |
|
|
newDir, _ := newEntry.DirAndName() |
|
|
newDir, _ := newEntry.DirAndName() |
|
|
if mc.visitedBoundary.HasVisited(util.FullPath(newDir)) { |
|
|
if mc.visitedBoundary.HasVisited(util.FullPath(newDir)) { |
|
|
glog.V(3).Infof("InsertEntry %s/%s", newDir,newEntry.Name()) |
|
|
|
|
|
|
|
|
glog.V(3).Infof("InsertEntry %s/%s", newDir, newEntry.Name()) |
|
|
if err := mc.localStore.InsertEntry(ctx, newEntry); err != nil { |
|
|
if err := mc.localStore.InsertEntry(ctx, newEntry); err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|