Skip to content

Commit

Permalink
Log cache usage
Browse files Browse the repository at this point in the history
  • Loading branch information
james58899 committed Jun 22, 2024
1 parent 037ce9e commit 2e0f008
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cache_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,18 @@ impl CacheManager {
async fn check_cache_usage(&self) {
let total_size = self.total_size.load(Relaxed);
let size_limit = self.size_limit.load(Relaxed).saturating_sub(SIZE_100MB); // Reserve 100MiB in size limit
let disk_free = get_available_space(&self.cache_dir);
let mut need_free = total_size.saturating_sub(size_limit);

if let Some(free) = get_available_space(&self.cache_dir) {
if let Some(free) = disk_free {
if free < SIZE_100MB {
warn!("Disk space is low than 100MiB: available={}MiB", free / 1024 / 1024);
need_free += SIZE_100MB.saturating_sub(free);
}
}

debug!("Cache usage: totel={total_size}bytes, limit={size_limit}bytes, available={disk_free:?}bytes");

if need_free == 0 {
return;
}
Expand Down

0 comments on commit 2e0f008

Please sign in to comment.