about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-24 11:39:17 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-24 11:45:31 +0200
commit324ddec41d474bb4840a2b76db48b5f97ed65889 (patch)
treeb5bd36bb1a4cc59fdf4996c6b1fa90578127255b /src
parentfeat(cli/selectCommand/file): Allow re-use of the previous selection file (diff)
downloadyt-324ddec41d474bb4840a2b76db48b5f97ed65889.tar.gz
yt-324ddec41d474bb4840a2b76db48b5f97ed65889.zip
fix(treewide): Always display bytes in a formatted way through `Bytes`
Diffstat (limited to 'src')
-rw-r--r--src/download/mod.rs8
-rw-r--r--src/main.rs6
2 files changed, 8 insertions, 6 deletions
diff --git a/src/download/mod.rs b/src/download/mod.rs
index ad807f6..2a19a3a 100644
--- a/src/download/mod.rs
+++ b/src/download/mod.rs
@@ -8,7 +8,7 @@
 // You should have received a copy of the License along with this program.
 // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 
-use std::{collections::HashMap, sync::Arc, time::Duration};
+use std::{collections::HashMap, str::FromStr, sync::Arc, time::Duration};
 
 use crate::{
     app::App,
@@ -24,7 +24,7 @@ use crate::{
 use anyhow::{bail, Context, Result};
 use bytes::Bytes;
 use futures::{future::BoxFuture, FutureExt};
-use log::{debug, info, warn};
+use log::{debug, error, info, warn};
 use tokio::{fs, task::JoinHandle, time};
 
 mod download_options;
@@ -156,8 +156,8 @@ impl Downloader {
         }
 
         let val = dir_size(fs::read_dir(&app.config.paths.download_dir).await?).await;
-        if let Ok(val) = val.as_ref() {
-            info!("Cache dir has a size of '{}'", val);
+        if let Ok(val) = val {
+            info!("Cache dir has a size of '{}'", Bytes::new(val));
         }
         val
     }
diff --git a/src/main.rs b/src/main.rs
index 0f22c22..7febefc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,6 +12,7 @@ use std::{collections::HashMap, fs, sync::Arc, u8};
 
 use anyhow::{bail, Context, Result};
 use app::App;
+use bytes::Bytes;
 use cache::invalidate;
 use clap::Parser;
 use cli::{CacheCommand, CheckCommand, SelectCommand, SubscriptionCommand, VideosCommand};
@@ -82,8 +83,9 @@ async fn main() -> Result<()> {
             force,
             max_cache_size,
         } => {
-            let max_cache_size = max_cache_size.unwrap_or(app.config.download.max_cache_size);
-            info!("max cache size: '{}'", max_cache_size);
+            let max_cache_size =
+                max_cache_size.unwrap_or(app.config.download.max_cache_size.as_u64());
+            info!("Max cache size: '{}'", Bytes::new(max_cache_size));
 
             if force {
                 invalidate(&app, true).await?;