MCPcopy
hub / github.com/rclone/rclone / ExpireDir

Method ExpireDir

backend/cache/storage_persistent.go:342–372  ·  view source on GitHub ↗

ExpireDir will flush a CachedDirectory and all its objects from the objects chunks will remain as they are

(cd *Directory)

Source from the content-addressed store, hash-verified

340// ExpireDir will flush a CachedDirectory and all its objects from the objects
341// chunks will remain as they are
342func (b *Persistent) ExpireDir(cd *Directory) error {
343 t := time.Now().Add(time.Duration(-cd.CacheFs.opt.InfoAge))
344 cd.CacheTs = &t
345
346 // expire all parents
347 return b.db.Update(func(tx *bolt.Tx) error {
348 // expire all the parents
349 currentDir := cd.abs()
350 for { // until we get to the root
351 bucket := b.getBucket(currentDir, false, tx)
352 if bucket != nil {
353 val := bucket.Get([]byte("."))
354 if val != nil {
355 cd2 := &Directory{CacheFs: cd.CacheFs}
356 err := json.Unmarshal(val, cd2)
357 if err == nil {
358 fs.Debugf(cd, "cache: expired %v", currentDir)
359 cd2.CacheTs = &t
360 enc2, _ := json.Marshal(cd2)
361 _ = bucket.Put([]byte("."), enc2)
362 }
363 }
364 }
365 if currentDir == "" {
366 break
367 }
368 currentDir = cleanPath(path.Dir(currentDir))
369 }
370 return nil
371 })
372}
373
374// GetObject will return a CachedObject from its parent directory or an error if it doesn't find it
375func (b *Persistent) GetObject(cachedObject *Object) (err error) {

Callers 10

runMethod · 0.80
httpExpireRemoteMethod · 0.80
receiveChangeNotifyMethod · 0.80
MkdirMethod · 0.80
RmdirMethod · 0.80
DirMoveMethod · 0.80
putMethod · 0.80
CopyMethod · 0.80
MoveMethod · 0.80
RemoveMethod · 0.80

Calls 9

getBucketMethod · 0.95
DebugfFunction · 0.92
cleanPathFunction · 0.85
DirMethod · 0.80
AddMethod · 0.65
UpdateMethod · 0.65
GetMethod · 0.65
PutMethod · 0.65
absMethod · 0.45

Tested by

no test coverage detected