about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/download/mod.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/download/mod.rs b/src/download/mod.rs
index 707f281..4aee136 100644
--- a/src/download/mod.rs
+++ b/src/download/mod.rs
@@ -22,6 +22,7 @@ use crate::{
 };
 
 use anyhow::{bail, Context, Result};
+use bytes::Bytes;
 use futures::{future::BoxFuture, FutureExt};
 use log::{debug, info, warn};
 use tokio::{fs, task::JoinHandle, time};
@@ -71,14 +72,14 @@ impl Downloader {
     /// This will run, until the database doesn't contain any watchable videos
     pub async fn consume(&mut self, app: Arc<App>, max_cache_size: u64) -> Result<()> {
         while let Some(next_video) = get_next_uncached_video(&app).await? {
-            if Self::get_current_cache_allocation(&app).await?
-                + self.get_approx_video_size(&app, &next_video).await?
-                >= max_cache_size
-            {
+            let cache_allocation = Self::get_current_cache_allocation(&app).await?;
+            let video_size = self.get_approx_video_size(&app, &next_video).await?;
+            if cache_allocation + video_size >= max_cache_size {
                 warn!(
-                    "Can't download video: '{}' as it's too large for the cache.",
-                    next_video.title
+                    "Can't download video: '{}' ({}) as it's too large for the cache ({} of {} allocated).",
+                    next_video.title, Bytes::new(video_size), Bytes::new(cache_allocation), Bytes::new(max_cache_size)
                 );
+
                 // Wait and hope, that a large video is deleted from the cache.
                 time::sleep(Duration::from_secs(10)).await;
                 continue;