Skip to content

Commit

Permalink
Foreground cache scan when free space is low
Browse files Browse the repository at this point in the history
  • Loading branch information
james58899 committed Jun 27, 2024
1 parent 6024d66 commit 2112f77
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/cache_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,19 @@ impl CacheManager {
let manager = new.clone();
let verify_cache = init_settings.verify_cache();
let static_range = init_settings.static_range();
if verify_cache && !force_background_scan {
// Force check cache
info!("Start force cache check");
let low_disk = if let Some(free) = get_available_space(cache_dir.as_ref()) {
warn!("Disk space is low than 100MiB: available={}MiB", free / 1024 / 1024);
free < SIZE_100MB
} else {
false
};
if low_disk || (verify_cache && !force_background_scan) {
// Low space or force cache check
if low_disk {
info!("Start foreground cache scan due to low disk space");
} else {
info!("Start force cache check");
}
new.scan_cache(static_range, 16, verify_cache).await?;
CacheManager::start_background_task(manager);
} else {
Expand Down

0 comments on commit 2112f77

Please sign in to comment.