()
| 537 | const idleCacheCleanDelay = 30 * time.Second |
| 538 | |
| 539 | func (s *Session) scheduleIdleCacheClean() { |
| 540 | s.idleCacheCleanMu.Lock() |
| 541 | defer s.idleCacheCleanMu.Unlock() |
| 542 | |
| 543 | if s.idleCacheCleanTimer != nil { |
| 544 | s.idleCacheCleanTimer.Stop() |
| 545 | } |
| 546 | |
| 547 | s.idleCacheCleanTimer = time.AfterFunc(idleCacheCleanDelay, func() { |
| 548 | s.idleCacheCleanMu.Lock() |
| 549 | s.idleCacheCleanTimer = nil |
| 550 | s.idleCacheCleanMu.Unlock() |
| 551 | |
| 552 | s.snapshotUpdateMu.Lock() |
| 553 | defer s.snapshotUpdateMu.Unlock() |
| 554 | s.cancelScheduledSnapshotUpdate() |
| 555 | |
| 556 | ctx := s.backgroundCtx |
| 557 | fileChanges, overlays, ataChanges, newConfig := s.flushChanges(ctx) |
| 558 | s.UpdateSnapshot(ctx, overlays, SnapshotChange{ |
| 559 | reason: UpdateReasonIdleCleanDiskCache, |
| 560 | fileChanges: fileChanges, |
| 561 | ataChanges: ataChanges, |
| 562 | newConfig: newConfig, |
| 563 | cleanDiskCache: true, |
| 564 | }) |
| 565 | |
| 566 | go func() { runtime.GC() }() |
| 567 | }) |
| 568 | } |
| 569 | |
| 570 | func (s *Session) cancelIdleCacheClean() { |
| 571 | s.idleCacheCleanMu.Lock() |
no test coverage detected