From d71f3efe57646d639ae19b26dbea5115c219557c Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Thu, 22 Aug 2024 20:23:53 +0200 Subject: refactor(storage): Make all URL parsings panic These URLs should be checked *before* they are written to the database, thus being unable to decode them after they've been read from the database is an application bug and not a user input issue. --- src/storage/video_database/downloader.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/storage/video_database/downloader.rs') diff --git a/src/storage/video_database/downloader.rs b/src/storage/video_database/downloader.rs index c04ab8d..a7f6cad 100644 --- a/src/storage/video_database/downloader.rs +++ b/src/storage/video_database/downloader.rs @@ -43,7 +43,7 @@ pub async fn get_next_uncached_video(app: &App) -> Result> { let base = result?; let thumbnail_url = if let Some(url) = &base.thumbnail_url { - Some(Url::parse(&url)?) + Some(Url::parse(&url).expect("Parsing this as url should always work")) } else { None }; @@ -72,7 +72,7 @@ pub async fn get_next_uncached_video(app: &App) -> Result> { status_change, thumbnail_url, title: base.title.clone(), - url: Url::parse(&base.url)?, + url: Url::parse(&base.url).expect("Parsing this as url should always work"), }; Ok(Some(video)) @@ -100,7 +100,7 @@ pub async fn get_next_video_watchable(app: &App) -> Result> { let base = result?; let thumbnail_url = if let Some(url) = &base.thumbnail_url { - Some(Url::parse(&url)?) + Some(Url::parse(&url).expect("Parsing this as url should always work")) } else { None }; @@ -129,7 +129,7 @@ pub async fn get_next_video_watchable(app: &App) -> Result> { status_change, thumbnail_url, title: base.title.clone(), - url: Url::parse(&base.url)?, + url: Url::parse(&base.url).expect("Parsing this as url should always work"), }; Ok(Some(video)) -- cgit 1.4.1