mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-07-25 13:50:51 +02:00
refactor: better error handling and prevention of creating ephemeral password protected profiles
This commit is contained in:
@@ -185,6 +185,7 @@ impl ProfileManager {
|
||||
created_by_email: None,
|
||||
dns_blocklist: None,
|
||||
password_protected: false,
|
||||
created_at: None,
|
||||
};
|
||||
|
||||
match self
|
||||
@@ -287,6 +288,7 @@ impl ProfileManager {
|
||||
created_by_email: None,
|
||||
dns_blocklist: None,
|
||||
password_protected: false,
|
||||
created_at: None,
|
||||
};
|
||||
|
||||
match self
|
||||
@@ -343,6 +345,12 @@ impl ProfileManager {
|
||||
created_by_email: None,
|
||||
dns_blocklist,
|
||||
password_protected: false,
|
||||
created_at: Some(
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.map(|d| d.as_secs())
|
||||
.unwrap_or(0),
|
||||
),
|
||||
};
|
||||
|
||||
// Save profile info
|
||||
@@ -989,6 +997,12 @@ impl ProfileManager {
|
||||
created_by_email: None,
|
||||
dns_blocklist: source.dns_blocklist,
|
||||
password_protected: false,
|
||||
created_at: Some(
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.map(|d| d.as_secs())
|
||||
.unwrap_or(0),
|
||||
),
|
||||
};
|
||||
|
||||
self.save_profile(&new_profile)?;
|
||||
|
||||
@@ -233,6 +233,15 @@ pub async fn set_profile_password(profile_id: String, password: String) -> Resul
|
||||
return Err(err_code("PROFILE_ALREADY_PROTECTED"));
|
||||
}
|
||||
|
||||
// Ephemeral profiles live in RAM-backed dirs that get wiped on quit, so
|
||||
// there's no on-disk data to encrypt. The two features are mutually
|
||||
// exclusive by design — fail loudly rather than silently producing a
|
||||
// half-broken state where `password_protected` is true but the encrypted
|
||||
// dir vanishes between launches.
|
||||
if profile.ephemeral {
|
||||
return Err(err_code("PROFILE_EPHEMERAL"));
|
||||
}
|
||||
|
||||
if profile
|
||||
.process_id
|
||||
.is_some_and(crate::proxy_storage::is_process_running)
|
||||
|
||||
@@ -73,6 +73,11 @@ pub struct BrowserProfile {
|
||||
/// Decryption goes to a RAM-backed ephemeral dir, never to disk.
|
||||
#[serde(default)]
|
||||
pub password_protected: bool,
|
||||
/// Profile creation timestamp (epoch seconds, UTC). `None` for legacy
|
||||
/// profiles that pre-date this field — those are treated as ancient by
|
||||
/// any staleness check.
|
||||
#[serde(default)]
|
||||
pub created_at: Option<u64>,
|
||||
}
|
||||
|
||||
pub fn default_release_type() -> String {
|
||||
|
||||
Reference in New Issue
Block a user