Implement desktop help settings and about
This commit is contained in:
@@ -82,11 +82,14 @@ impl DesktopStorage {
|
||||
}
|
||||
|
||||
pub fn system() -> Result<DesktopBootstrap, DesktopError> {
|
||||
let storage = Self::load(None)?;
|
||||
let keys = KeyStore::load(storage.config.key_material())
|
||||
Self::load(None)?.bootstrap()
|
||||
}
|
||||
|
||||
pub fn bootstrap(self) -> Result<DesktopBootstrap, DesktopError> {
|
||||
let keys = KeyStore::load(self.config.key_material())
|
||||
.map_err(|error| DesktopError::new(DesktopErrorKind::KeyMaterial, error))?;
|
||||
let handle = keys
|
||||
.resolve(storage.config.default_key().as_str())
|
||||
.resolve(self.config.default_key().as_str())
|
||||
.map_err(|error| DesktopError::new(DesktopErrorKind::KeyMaterial, error))?;
|
||||
let key = keys
|
||||
.infos()
|
||||
@@ -99,11 +102,11 @@ impl DesktopStorage {
|
||||
})?;
|
||||
let authentication = NativeAuthenticationSession::system(
|
||||
SecretProtectionPolicy::default(),
|
||||
storage.config.authentication_timeout(),
|
||||
self.config.authentication_timeout(),
|
||||
)
|
||||
.map_err(|error| DesktopError::new(DesktopErrorKind::Authentication, error))?;
|
||||
Ok(DesktopBootstrap {
|
||||
storage,
|
||||
storage: self,
|
||||
authentication,
|
||||
key,
|
||||
})
|
||||
@@ -137,7 +140,22 @@ impl DesktopStorage {
|
||||
self.config.settings()
|
||||
}
|
||||
|
||||
pub fn update_settings(&self, mut settings: ConfigSettings) -> Result<Self, DesktopError> {
|
||||
pub fn update_settings(&self, settings: ConfigSettings) -> Result<Self, DesktopError> {
|
||||
let storage = self.validate_settings(settings)?;
|
||||
storage.persist()?;
|
||||
Ok(storage)
|
||||
}
|
||||
|
||||
pub fn update_settings_and_bootstrap(
|
||||
&self,
|
||||
settings: ConfigSettings,
|
||||
) -> Result<DesktopBootstrap, DesktopError> {
|
||||
let bootstrap = self.validate_settings(settings)?.bootstrap()?;
|
||||
bootstrap.storage.persist()?;
|
||||
Ok(bootstrap)
|
||||
}
|
||||
|
||||
fn validate_settings(&self, mut settings: ConfigSettings) -> Result<Self, DesktopError> {
|
||||
let repository = Repository::open(settings.vault())
|
||||
.map_err(|error| DesktopError::new(DesktopErrorKind::Repository, error))?;
|
||||
settings.set_vault(repository.root_path().to_owned());
|
||||
@@ -150,13 +168,15 @@ impl DesktopStorage {
|
||||
keys.resolve(storage.config.default_key().as_str())
|
||||
.map_err(|error| DesktopError::new(DesktopErrorKind::KeyMaterial, error))?;
|
||||
storage.tree()?;
|
||||
storage
|
||||
.config
|
||||
.persist()
|
||||
.map_err(|error| DesktopError::new(DesktopErrorKind::Configuration, error))?;
|
||||
Ok(storage)
|
||||
}
|
||||
|
||||
fn persist(&self) -> Result<(), DesktopError> {
|
||||
self.config
|
||||
.persist()
|
||||
.map_err(|error| DesktopError::new(DesktopErrorKind::Configuration, error))
|
||||
}
|
||||
|
||||
/// Validate a selected folder through the same repository and key path as
|
||||
/// normal desktop reads, then atomically update the shared configuration.
|
||||
pub fn switch_vault(&self, vault: &Path) -> Result<Self, DesktopError> {
|
||||
|
||||
Reference in New Issue
Block a user