MCPcopy
hub / github.com/rclone/rclone / GetDir

Method GetDir

backend/cache/storage_persistent.go:171–189  ·  view source on GitHub ↗

GetDir will retrieve data of a cached directory

(remote string)

Source from the content-addressed store, hash-verified

169
170// GetDir will retrieve data of a cached directory
171func (b *Persistent) GetDir(remote string) (*Directory, error) {
172 cd := &Directory{}
173
174 err := b.db.View(func(tx *bolt.Tx) error {
175 bucket := b.getBucket(remote, false, tx)
176 if bucket == nil {
177 return fmt.Errorf("couldn't open bucket (%v)", remote)
178 }
179
180 data := bucket.Get([]byte("."))
181 if data != nil {
182 return json.Unmarshal(data, cd)
183 }
184
185 return fmt.Errorf("%v not found", remote)
186 })
187
188 return cd, err
189}
190
191// AddDir will update a CachedDirectory metadata and all its entries
192func (b *Persistent) AddDir(cachedDir *Directory) error {

Callers 1

ListMethod · 0.45

Calls 3

getBucketMethod · 0.95
GetMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected