-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement StorageEventLogs for fs client storage.
- Loading branch information
Showing
7 changed files
with
111 additions
and
54 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use crate::{ClientFolderStorage, Error, Result}; | ||
use async_trait::async_trait; | ||
use indexmap::IndexSet; | ||
use sos_backend::{ | ||
AccountEventLog, DeviceEventLog, FolderEventLog, StorageError, | ||
}; | ||
use sos_core::VaultId; | ||
use sos_sync::StorageEventLogs; | ||
use sos_vault::Summary; | ||
use std::sync::Arc; | ||
use tokio::sync::RwLock; | ||
|
||
#[cfg(feature = "files")] | ||
use sos_backend::FileEventLog; | ||
|
||
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] | ||
#[cfg_attr(not(target_arch = "wasm32"), async_trait)] | ||
impl StorageEventLogs for super::ClientStorage { | ||
type Error = Error; | ||
|
||
async fn identity_log(&self) -> Result<Arc<RwLock<FolderEventLog>>> { | ||
Ok(self.identity_log.clone()) | ||
} | ||
|
||
async fn account_log(&self) -> Result<Arc<RwLock<AccountEventLog>>> { | ||
Ok(self.account_log.clone()) | ||
} | ||
|
||
async fn device_log(&self) -> Result<Arc<RwLock<DeviceEventLog>>> { | ||
Ok(self.device_log.clone()) | ||
} | ||
|
||
#[cfg(feature = "files")] | ||
async fn file_log(&self) -> Result<Arc<RwLock<FileEventLog>>> { | ||
Ok(self.file_log.clone()) | ||
} | ||
|
||
async fn folder_details(&self) -> Result<IndexSet<Summary>> { | ||
let folders = self.list_folders(); | ||
Ok(folders.into_iter().cloned().collect()) | ||
} | ||
|
||
async fn folder_log( | ||
&self, | ||
id: &VaultId, | ||
) -> Result<Arc<RwLock<FolderEventLog>>> { | ||
let folder = self | ||
.folders | ||
.get(id) | ||
.ok_or(StorageError::CacheNotAvailable(*id))?; | ||
Ok(folder.event_log()) | ||
} | ||
} |