Add profile download policy
This commit is contained in:
@@ -13,10 +13,12 @@ impl BrowserCore {
|
||||
file_name: impl Into<String>,
|
||||
total_bytes: Option<u64>,
|
||||
) -> Result<DownloadId, CoreError> {
|
||||
let destination = self.active_profile()?.download_policy().destination().clone();
|
||||
let entry = DownloadEntry::started(
|
||||
self.active_profile_id.clone(),
|
||||
source_url,
|
||||
file_name,
|
||||
destination,
|
||||
total_bytes,
|
||||
SystemTime::now(),
|
||||
)?;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ely_domain::{Profile, ProfileId, ProfileKind, TabId};
|
||||
use ely_domain::{DownloadPolicy, Profile, ProfileId, ProfileKind, TabId};
|
||||
|
||||
use crate::CoreError;
|
||||
|
||||
@@ -66,4 +66,19 @@ impl BrowserCore {
|
||||
self.select_tab(&tab_id)?;
|
||||
Ok(tab_id)
|
||||
}
|
||||
|
||||
pub fn set_profile_download_policy(
|
||||
&mut self,
|
||||
profile_id: &ProfileId,
|
||||
download_policy: DownloadPolicy,
|
||||
) -> Result<(), CoreError> {
|
||||
let profile = self
|
||||
.profiles
|
||||
.iter_mut()
|
||||
.find(|profile| profile.id() == profile_id)
|
||||
.ok_or_else(|| CoreError::ProfileNotFound { id: profile_id.clone() })?;
|
||||
|
||||
profile.set_download_policy(download_policy);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user