File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -598,3 +598,36 @@ func (c *BlobCacheClient) IsPathCachedNearby(ctx context.Context, path string) b
598598
599599 return c .IsCachedNearby (ctx , metadata .Hash )
600600}
601+
602+ func (c * BlobCacheClient ) IsDirCachedNearby (ctx context.Context , path string ) bool {
603+ metadata , err := c .metadata .GetFsNode (ctx , GenerateFsID (path ))
604+ if err != nil {
605+ Logger .Errorf ("error getting fs node: %v, path: %s" , err , path )
606+ return false
607+ }
608+
609+ return c .childrenCachedNearby (ctx , metadata .ID )
610+ }
611+
612+ func (c * BlobCacheClient ) childrenCachedNearby (ctx context.Context , id string ) bool {
613+ children , err := c .metadata .GetFsNodeChildren (ctx , id )
614+ if err != nil {
615+ Logger .Errorf ("error getting fs node children: %v, id: %s" , err , id )
616+ return false
617+ }
618+
619+ for _ , child := range children {
620+ if (child .Mode & fuse .S_IFDIR ) != 0 {
621+ if ! c .childrenCachedNearby (ctx , child .ID ) {
622+ return false
623+ }
624+ continue
625+ }
626+
627+ if ! c .IsCachedNearby (ctx , child .Hash ) {
628+ return false
629+ }
630+ }
631+
632+ return true
633+ }
You can’t perform that action at this time.
0 commit comments