about summary refs log tree commit diff stats
path: root/pkgs/by-name/yt/yt/src/cache/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/yt/yt/src/cache/mod.rs72
1 files changed, 0 insertions, 72 deletions
diff --git a/pkgs/by-name/yt/yt/src/cache/mod.rs b/pkgs/by-name/yt/yt/src/cache/mod.rs
deleted file mode 100644
index 6aa3a161..00000000
--- a/pkgs/by-name/yt/yt/src/cache/mod.rs
+++ /dev/null
@@ -1,72 +0,0 @@
-use anyhow::Result;
-use log::info;
-use tokio::fs;
-
-use crate::{
-    app::App,
-    storage::video_database::{
-        downloader::set_video_cache_path, getters::get_videos, setters::set_state_change, Video,
-        VideoStatus,
-    },
-};
-
-async fn invalidate_video(app: &App, video: &Video, hard: bool) -> Result<()> {
-    info!("Invalidating cache of video: '{}'", video.title);
-
-    if hard {
-        if let Some(path) = &video.cache_path {
-            info!("Removing cached video at: '{}'", path.display());
-            fs::remove_file(path).await?;
-        }
-    }
-
-    set_video_cache_path(app, &video.extractor_hash, None).await?;
-
-    Ok(())
-}
-
-pub async fn invalidate(app: &App, hard: bool) -> Result<()> {
-    let all_cached_things = get_videos(app, &[VideoStatus::Cached], None).await?;
-
-    info!("Got videos to invalidate: '{}'", all_cached_things.len());
-
-    for video in all_cached_things {
-        invalidate_video(app, &video, hard).await?
-    }
-
-    Ok(())
-}
-
-pub async fn maintain(app: &App, all: bool) -> Result<()> {
-    let domain = if all {
-        vec![
-            VideoStatus::Pick,
-            //
-            VideoStatus::Watch,
-            VideoStatus::Cached,
-            VideoStatus::Watched,
-            //
-            VideoStatus::Drop,
-            VideoStatus::Dropped,
-        ]
-    } else {
-        vec![VideoStatus::Watch, VideoStatus::Cached]
-    };
-
-    let cached_videos = get_videos(app, domain.as_slice(), None).await?;
-
-    for vid in cached_videos {
-        if let Some(path) = vid.cache_path.as_ref() {
-            info!("Checking if path ('{}') exists", path.display());
-            if !path.exists() {
-                invalidate_video(app, &vid, false).await?;
-            }
-        }
-        if vid.status_change {
-            info!("Video '{}' has it's changing bit set. This is probably the result of an unexpectet exit. Clearing it", vid.title);
-            set_state_change(app, &vid.extractor_hash, false).await?;
-        }
-    }
-
-    Ok(())
-}