Add download file actions

This commit is contained in:
2026-05-07 21:56:09 -04:00
parent f3c9a933c9
commit 7370ae14b9
11 changed files with 248 additions and 4 deletions
+3
View File
@@ -18,6 +18,9 @@ pub enum CoreError {
#[error("download not found: {id}")]
DownloadNotFound { id: DownloadId },
#[error("download target path is unavailable: {id}")]
DownloadTargetPathUnavailable { id: DownloadId },
#[error("favorite limit reached: {limit}")]
FavoriteLimitReached { limit: usize },
+23 -1
View File
@@ -1,4 +1,4 @@
use std::time::SystemTime;
use std::{path::PathBuf, time::SystemTime};
use ely_domain::{DownloadEntry, DownloadId, UrlText};
@@ -70,6 +70,17 @@ impl BrowserCore {
Ok(())
}
pub fn download_target_file_path(
&self,
download_id: &DownloadId,
) -> Result<PathBuf, CoreError> {
let entry = self.visible_download_entry(download_id)?;
entry
.target_file_path()
.map(PathBuf::from)
.ok_or_else(|| CoreError::DownloadTargetPathUnavailable { id: download_id.clone() })
}
pub(super) fn visible_downloads(&self) -> Vec<DownloadEntry> {
self.download_entries
.iter()
@@ -78,6 +89,17 @@ impl BrowserCore {
.collect()
}
fn visible_download_entry(
&self,
download_id: &DownloadId,
) -> Result<&DownloadEntry, CoreError> {
self.download_entries
.iter()
.filter(|entry| entry.profile_id() == &self.active_profile_id)
.find(|entry| entry.id() == download_id)
.ok_or_else(|| CoreError::DownloadNotFound { id: download_id.clone() })
}
fn download_entry_mut(
&mut self,
download_id: &DownloadId,