about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/storage/video_database/setters.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/storage/video_database/setters.rs b/src/storage/video_database/setters.rs
index fcafcd4..c160138 100644
--- a/src/storage/video_database/setters.rs
+++ b/src/storage/video_database/setters.rs
@@ -12,7 +12,7 @@
 
 use anyhow::Result;
 use chrono::Utc;
-use log::debug;
+use log::{debug, info};
 use sqlx::query;
 use tokio::fs;
 
@@ -116,6 +116,8 @@ pub async fn set_video_watched(app: &App, video: &Video) -> Result<()> {
     let video_hash = video.extractor_hash.hash().to_string();
     let new_status = VideoStatus::Watched.as_db_integer();
 
+    info!("Will set video watched: '{}'", video.title);
+
     let old = query!(
         r#"
     SELECT status, priority
@@ -127,9 +129,15 @@ pub async fn set_video_watched(app: &App, video: &Video) -> Result<()> {
     .fetch_one(&app.database)
     .await?;
 
-    if old.status == new_status {
-        unreachable!("The video should not be marked as watched already.")
-    }
+    assert_ne!(
+        old.status, new_status,
+        "The video should not be marked as watched already."
+    );
+    assert_eq!(
+        old.status,
+        VideoStatus::Cached.as_db_integer(),
+        "The video should have been marked cached"
+    );
 
     let now = Utc::now().timestamp();
 
@@ -180,7 +188,7 @@ pub async fn set_state_change(
 
 pub async fn set_video_options(
     app: &App,
-    hash: ExtractorHash,
+    hash: &ExtractorHash,
     video_options: &VideoOptions,
 ) -> Result<()> {
     let video_extractor_hash = hash.hash().to_string();