MCPcopy
hub / github.com/kopia/kopia / IterateEntries

Method IterateEntries

fs/cachefs/cache.go:88–116  ·  view source on GitHub ↗

IterateEntries reads the contents of a provided directory using ObjectID of a directory (if any) to cache the results. The given callback is invoked on each item in the directory.

(ctx context.Context, d fs.Directory, w EntryWrapper, callback func(context.Context, fs.Entry) error)

Source from the content-addressed store, hash-verified

86// IterateEntries reads the contents of a provided directory using ObjectID of a directory (if any) to cache
87// the results. The given callback is invoked on each item in the directory.
88func (c *Cache) IterateEntries(ctx context.Context, d fs.Directory, w EntryWrapper, callback func(context.Context, fs.Entry) error) error {
89 if h, ok := d.(object.HasObjectID); ok {
90 cacheID := h.ObjectID().String()
91
92 entries, err := c.getEntries(
93 ctx,
94 cacheID,
95 dirCacheExpiration,
96 func(innerCtx context.Context) ([]fs.Entry, error) {
97 return fs.GetAllEntries(innerCtx, d)
98 },
99 w,
100 )
101 if err != nil {
102 return err
103 }
104
105 for _, e := range entries {
106 err = callback(ctx, e)
107 if err != nil {
108 return err
109 }
110 }
111
112 return nil
113 }
114
115 return fs.IterateEntries(ctx, d, callback) //nolint:wrapcheck
116}
117
118func (c *Cache) getEntriesFromCacheLocked(ctx context.Context, id string) []fs.Entry {
119 if v, ok := c.data[id]; id != "" && ok {

Callers

nothing calls this directly

Calls 6

getEntriesMethod · 0.95
GetAllEntriesFunction · 0.92
IterateEntriesFunction · 0.92
callbackFuncType · 0.85
ObjectIDMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected