ExpireDir will flush a CachedDirectory and all its objects from the objects chunks will remain as they are
(cd *Directory)
| 340 | // ExpireDir will flush a CachedDirectory and all its objects from the objects |
| 341 | // chunks will remain as they are |
| 342 | func (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 |
| 375 | func (b *Persistent) GetObject(cachedObject *Object) (err error) { |
no test coverage detected