feat(downloads): add dedicated Torrent category

This commit is contained in:
NimBold
2026-08-10 14:20:50 +03:30
parent 23991c3dea
commit 472da5a681
22 changed files with 150 additions and 25 deletions
+21 -1
View File
@@ -486,7 +486,9 @@ pub fn get_file_category(filename: String) -> DownloadCategory {
"run", "sh", "bin", "jar",
];
if music_exts.contains(&ext.as_str()) {
if ext == "torrent" {
DownloadCategory::Torrents
} else if music_exts.contains(&ext.as_str()) {
DownloadCategory::Musics
} else if movie_exts.contains(&ext.as_str()) {
DownloadCategory::Movies
@@ -689,3 +691,21 @@ pub fn is_supported_media(url: String) -> bool {
}
false
}
#[cfg(test)]
mod tests {
use super::get_file_category;
use crate::ipc::DownloadCategory;
#[test]
fn classifies_torrent_files_as_torrents() {
assert!(matches!(
get_file_category("Example.TORRENT".to_string()),
DownloadCategory::Torrents
));
assert!(matches!(
get_file_category("Example.mkv".to_string()),
DownloadCategory::Movies
));
}
}