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/getters.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/storage/video_database/getters.rs') diff --git a/src/storage/video_database/getters.rs b/src/storage/video_database/getters.rs index fd363fb..b912276 100644 --- a/src/storage/video_database/getters.rs +++ b/src/storage/video_database/getters.rs @@ -33,7 +33,7 @@ use super::{MpvOptions, VideoOptions, VideoStatus, YtDlpOptions}; macro_rules! video_from_record { ($record:expr) => { let thumbnail_url = if let Some(url) = &$record.thumbnail_url { - Some(Url::parse(&url)?) + Some(Url::parse(&url).expect("Parsing this as url should always work")) } else { None }; @@ -54,7 +54,7 @@ macro_rules! video_from_record { status: VideoStatus::from_db_integer($record.status), thumbnail_url, title: $record.title.clone(), - url: Url::parse(&$record.url)?, + url: Url::parse(&$record.url).expect("Parsing this as url should always work"), priority: $record.priority, status_change: if $record.status_change == 1 { true @@ -147,7 +147,7 @@ pub async fn get_videos( status: VideoStatus::from_db_integer(base.get("status")), thumbnail_url, title: base.get::("title").to_owned(), - url: Url::parse(base.get("url"))?, + url: Url::parse(base.get("url")).expect("Parsing this as url should always work"), priority: base.get("priority"), status_change: { let val = base.get::("status_change"); -- cgit 1.4.1