Skip to content

Commit

Permalink
Rename UpdateManifestData to ManifestData
Browse files Browse the repository at this point in the history
  • Loading branch information
FirelightFlagboy committed Jul 31, 2024
1 parent 0931303 commit 15f8ed7
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 53 deletions.
6 changes: 3 additions & 3 deletions libparsec/crates/client/src/workspace/store/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::{collections::HashMap, sync::Arc};

use libparsec_platform_storage::workspace::{PopulateManifestOutcome, UpdateManifestData};
use libparsec_platform_storage::workspace::{PopulateManifestOutcome, ManifestData};
use libparsec_types::prelude::*;

use crate::{
Expand Down Expand Up @@ -354,13 +354,13 @@ pub(super) async fn populate_cache_from_local_storage_or_server(
};

let update_data = match &manifest {
ArcLocalChildManifest::File(manifest) => UpdateManifestData {
ArcLocalChildManifest::File(manifest) => ManifestData {
entry_id: manifest.base.id,
base_version: manifest.base.version,
need_sync: manifest.need_sync,
encrypted: manifest.dump_and_encrypt(&store.device.local_symkey),
},
ArcLocalChildManifest::Folder(manifest) => UpdateManifestData {
ArcLocalChildManifest::Folder(manifest) => ManifestData {
entry_id: manifest.base.id,
base_version: manifest.base.version,
need_sync: manifest.need_sync,
Expand Down
4 changes: 2 additions & 2 deletions libparsec/crates/client/src/workspace/store/file_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;
use libparsec_types::prelude::*;

use crate::certif::{InvalidCertificateError, InvalidKeysBundleError, InvalidManifestError};
use libparsec_platform_storage::workspace::UpdateManifestData;
use libparsec_platform_storage::workspace::ManifestData;

use super::per_manifest_update_lock::ManifestUpdateLockTakeOutcome;
use super::{
Expand Down Expand Up @@ -170,7 +170,7 @@ impl FileUpdater {
.as_mut()
.ok_or_else(|| UpdateFileManifestAndContinueError::Stopped)?;

let update_data = UpdateManifestData {
let update_data = ManifestData {
entry_id: manifest.base.id,
base_version: manifest.base.version,
need_sync: manifest.need_sync,
Expand Down
8 changes: 4 additions & 4 deletions libparsec/crates/client/src/workspace/store/folder_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;
use libparsec_types::prelude::*;

use crate::certif::{InvalidCertificateError, InvalidKeysBundleError, InvalidManifestError};
use libparsec_platform_storage::workspace::UpdateManifestData;
use libparsec_platform_storage::workspace::ManifestData;

use super::per_manifest_update_lock::ManifestUpdateLockTakeOutcome;
use super::{
Expand Down Expand Up @@ -207,7 +207,7 @@ impl<'a> FolderUpdater<'a> {
.as_mut()
.ok_or_else(|| UpdateFolderManifestError::Stopped)?;

let update_data = UpdateManifestData {
let update_data = ManifestData {
entry_id: manifest.base.id,
base_version: manifest.base.version,
need_sync: manifest.need_sync,
Expand All @@ -231,13 +231,13 @@ impl<'a> FolderUpdater<'a> {

Some(new_child) => {
let new_child_update_data = match &new_child {
ArcLocalChildManifest::File(new_child) => UpdateManifestData {
ArcLocalChildManifest::File(new_child) => ManifestData {
entry_id: new_child.base.id,
base_version: new_child.base.version,
need_sync: new_child.need_sync,
encrypted: new_child.dump_and_encrypt(&self.store.device.local_symkey),
},
ArcLocalChildManifest::Folder(new_child) => UpdateManifestData {
ArcLocalChildManifest::Folder(new_child) => ManifestData {
entry_id: new_child.base.id,
base_version: new_child.base.version,
need_sync: new_child.need_sync,
Expand Down
4 changes: 2 additions & 2 deletions libparsec/crates/client/src/workspace/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{

use libparsec_client_connection::AuthenticatedCmds;
use libparsec_platform_async::lock::Mutex as AsyncMutex;
use libparsec_platform_storage::workspace::{UpdateManifestData, WorkspaceStorage};
use libparsec_platform_storage::workspace::{ManifestData, WorkspaceStorage};
use libparsec_types::prelude::*;

use crate::{
Expand Down Expand Up @@ -160,7 +160,7 @@ impl WorkspaceStore {
// We must store the speculative manifest in local storage, otherwise there
// is no way for the outbound sync monitors to realize a synchronization is
// needed here !
let update_data = UpdateManifestData {
let update_data = ManifestData {
entry_id: manifest.0.base.id,
base_version: manifest.0.base.version,
need_sync: manifest.0.need_sync,
Expand Down
14 changes: 7 additions & 7 deletions libparsec/crates/client/src/workspace/store/reparent_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;
use libparsec_types::prelude::*;

use crate::workspace::store::resolve_path::ResolvePathForReparentingError;
use libparsec_platform_storage::workspace::UpdateManifestData;
use libparsec_platform_storage::workspace::ManifestData;

use super::per_manifest_update_lock::ManifestUpdateLockGuard;

Expand Down Expand Up @@ -110,27 +110,27 @@ impl ReparentingUpdater<'_> {

// 1) Insert in database

let src_parent_update_data = UpdateManifestData {
let src_parent_update_data = ManifestData {
entry_id: src_parent_manifest.base.id,
base_version: src_parent_manifest.base.version,
need_sync: src_parent_manifest.need_sync,
encrypted: src_parent_manifest.dump_and_encrypt(&store.device.local_symkey),
};
let src_child_update_data = match &src_child_manifest {
ArcLocalChildManifest::File(src_child_manifest) => UpdateManifestData {
ArcLocalChildManifest::File(src_child_manifest) => ManifestData {
entry_id: src_child_manifest.base.id,
base_version: src_child_manifest.base.version,
need_sync: src_child_manifest.need_sync,
encrypted: src_child_manifest.dump_and_encrypt(&store.device.local_symkey),
},
ArcLocalChildManifest::Folder(src_child_manifest) => UpdateManifestData {
ArcLocalChildManifest::Folder(src_child_manifest) => ManifestData {
entry_id: src_child_manifest.base.id,
base_version: src_child_manifest.base.version,
need_sync: src_child_manifest.need_sync,
encrypted: src_child_manifest.dump_and_encrypt(&store.device.local_symkey),
},
};
let dst_parent_update_data = UpdateManifestData {
let dst_parent_update_data = ManifestData {
entry_id: dst_parent_manifest.base.id,
base_version: dst_parent_manifest.base.version,
need_sync: dst_parent_manifest.need_sync,
Expand All @@ -155,13 +155,13 @@ impl ReparentingUpdater<'_> {
// 4 manifests to update (including destination child manifest)
Some(dst_child_manifest) => {
let dst_child_update_data = match &dst_child_manifest {
ArcLocalChildManifest::File(dst_child_manifest) => UpdateManifestData {
ArcLocalChildManifest::File(dst_child_manifest) => ManifestData {
entry_id: dst_child_manifest.base.id,
base_version: dst_child_manifest.base.version,
need_sync: dst_child_manifest.need_sync,
encrypted: dst_child_manifest.dump_and_encrypt(&store.device.local_symkey),
},
ArcLocalChildManifest::Folder(dst_child_manifest) => UpdateManifestData {
ArcLocalChildManifest::Folder(dst_child_manifest) => ManifestData {
entry_id: dst_child_manifest.base.id,
base_version: dst_child_manifest.base.version,
need_sync: dst_child_manifest.need_sync,
Expand Down
18 changes: 9 additions & 9 deletions libparsec/crates/client/src/workspace/store/sync_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
},
InvalidCertificateError, InvalidKeysBundleError, InvalidManifestError,
};
use libparsec_platform_storage::workspace::UpdateManifestData;
use libparsec_platform_storage::workspace::ManifestData;

use super::{
cache::{
Expand Down Expand Up @@ -193,13 +193,13 @@ impl<'a> SyncUpdater<'a> {
.ok_or_else(|| UpdateManifestForSyncError::Stopped)?;

let update_data = match &manifest {
ArcLocalChildManifest::File(manifest) => UpdateManifestData {
ArcLocalChildManifest::File(manifest) => ManifestData {
entry_id: manifest.base.id,
base_version: manifest.base.version,
need_sync: manifest.need_sync,
encrypted: manifest.dump_and_encrypt(&self.store.device.local_symkey),
},
ArcLocalChildManifest::Folder(manifest) => UpdateManifestData {
ArcLocalChildManifest::Folder(manifest) => ManifestData {
entry_id: manifest.base.id,
base_version: manifest.base.version,
need_sync: manifest.need_sync,
Expand Down Expand Up @@ -245,7 +245,7 @@ impl<'a> SyncUpdater<'a> {
.as_mut()
.ok_or_else(|| UpdateManifestForSyncError::Stopped)?;

let update_data = UpdateManifestData {
let update_data = ManifestData {
entry_id: manifest.base.id,
base_version: manifest.base.version,
need_sync: manifest.need_sync,
Expand Down Expand Up @@ -473,35 +473,35 @@ impl<'a> SyncConflictUpdater<'a> {
.ok_or_else(|| UpdateManifestForSyncError::Stopped)?;

let child_update_data = match &child_manifest {
ArcLocalChildManifest::File(manifest) => UpdateManifestData {
ArcLocalChildManifest::File(manifest) => ManifestData {
entry_id: manifest.base.id,
base_version: manifest.base.version,
need_sync: manifest.need_sync,
encrypted: manifest.dump_and_encrypt(&self.store.device.local_symkey),
},
ArcLocalChildManifest::Folder(manifest) => UpdateManifestData {
ArcLocalChildManifest::Folder(manifest) => ManifestData {
entry_id: manifest.base.id,
base_version: manifest.base.version,
need_sync: manifest.need_sync,
encrypted: manifest.dump_and_encrypt(&self.store.device.local_symkey),
},
};

let parent_update_data = UpdateManifestData {
let parent_update_data = ManifestData {
entry_id: parent_manifest.base.id,
base_version: parent_manifest.base.version,
need_sync: parent_manifest.need_sync,
encrypted: parent_manifest.dump_and_encrypt(&self.store.device.local_symkey),
};

let conflicting_new_child_update_data = match &conflicting_new_child_manifest {
ArcLocalChildManifest::File(manifest) => UpdateManifestData {
ArcLocalChildManifest::File(manifest) => ManifestData {
entry_id: manifest.base.id,
base_version: manifest.base.version,
need_sync: manifest.need_sync,
encrypted: manifest.dump_and_encrypt(&self.store.device.local_symkey),
},
ArcLocalChildManifest::Folder(manifest) => UpdateManifestData {
ArcLocalChildManifest::Folder(manifest) => ManifestData {
entry_id: manifest.base.id,
base_version: manifest.base.version,
need_sync: manifest.need_sync,
Expand Down
16 changes: 8 additions & 8 deletions libparsec/crates/platform_storage/src/native/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use libparsec_types::prelude::*;

#[cfg(any(test, feature = "expose-test-methods"))]
use crate::workspace::{DebugBlock, DebugChunk, DebugDump, DebugVlob};
use crate::workspace::{PopulateManifestOutcome, RawEncryptedManifest, UpdateManifestData};
use crate::workspace::{ManifestData, PopulateManifestOutcome, RawEncryptedManifest};

use super::model::{
get_workspace_cache_storage_db_relative_path, get_workspace_storage_db_relative_path,
Expand Down Expand Up @@ -213,18 +213,18 @@ impl PlatformWorkspaceStorage {

pub async fn populate_manifest(
&mut self,
manifest: &UpdateManifestData,
manifest: &ManifestData,
) -> anyhow::Result<PopulateManifestOutcome> {
db_populate_manifest(&mut self.conn, manifest).await
}

pub async fn update_manifest(&mut self, manifest: &UpdateManifestData) -> anyhow::Result<()> {
pub async fn update_manifest(&mut self, manifest: &ManifestData) -> anyhow::Result<()> {
db_update_manifest(&mut self.conn, manifest).await
}

pub async fn update_manifests(
&mut self,
manifests: impl Iterator<Item = UpdateManifestData>,
manifests: impl Iterator<Item = ManifestData>,
) -> anyhow::Result<()> {
// Note transaction automatically rollbacks on drop
let mut transaction = self.conn.begin().await?;
Expand All @@ -239,7 +239,7 @@ impl PlatformWorkspaceStorage {

pub async fn update_manifest_and_chunks(
&mut self,
manifest: &UpdateManifestData,
manifest: &ManifestData,
new_chunks: impl Iterator<Item = (ChunkID, Vec<u8>)>,
removed_chunks: impl Iterator<Item = ChunkID>,
) -> anyhow::Result<()> {
Expand Down Expand Up @@ -546,7 +546,7 @@ pub async fn workspace_storage_non_speculative_init(
let manifest = LocalFolderManifest::new_root(device.device_id, realm_id, timestamp, false);

storage
.update_manifest(&UpdateManifestData {
.update_manifest(&ManifestData {
entry_id: manifest.base.id,
encrypted: manifest.dump_and_encrypt(&device.local_symkey),
need_sync: manifest.need_sync,
Expand Down Expand Up @@ -692,7 +692,7 @@ pub async fn db_get_block_and_update_accessed_on(

pub async fn db_populate_manifest(
executor: impl sqlx::Executor<'_, Database = sqlx::Sqlite>,
manifest: &UpdateManifestData,
manifest: &ManifestData,
) -> anyhow::Result<PopulateManifestOutcome> {
let result = sqlx::query(
" \
Expand Down Expand Up @@ -723,7 +723,7 @@ pub async fn db_populate_manifest(

async fn db_update_manifest(
executor: impl sqlx::Executor<'_, Database = sqlx::Sqlite>,
manifest: &UpdateManifestData,
manifest: &ManifestData,
) -> anyhow::Result<()> {
sqlx::query(
" \
Expand Down
10 changes: 5 additions & 5 deletions libparsec/crates/platform_storage/src/testbed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use libparsec_types::prelude::*;
use crate::{
certificates::CertificatesStorage,
user::UserStorage,
workspace::{UpdateManifestData, WorkspaceStorage},
workspace::{ManifestData, WorkspaceStorage},
};

const STORE_ENTRY_KEY: &str = "platform_storage";
Expand Down Expand Up @@ -289,7 +289,7 @@ pub(crate) async fn maybe_populate_workspace_storage(
if x.realm == realm_id && x.device == device.device_id =>
{
lazy_storage!()
.update_manifest(&UpdateManifestData {
.update_manifest(&ManifestData {
entry_id: x.local_manifest.base.id,
need_sync: x.local_manifest.need_sync,
base_version: x.local_manifest.base.version,
Expand All @@ -302,7 +302,7 @@ pub(crate) async fn maybe_populate_workspace_storage(
if x.realm == realm_id && x.device == device.device_id =>
{
lazy_storage!()
.update_manifest(&UpdateManifestData {
.update_manifest(&ManifestData {
entry_id: x.local_manifest.base.id,
need_sync: x.local_manifest.need_sync,
base_version: x.local_manifest.base.version,
Expand Down Expand Up @@ -332,7 +332,7 @@ pub(crate) async fn maybe_populate_workspace_storage(
if x.realm == realm_id && x.device == device.device_id =>
{
lazy_storage!()
.update_manifest(&UpdateManifestData {
.update_manifest(&ManifestData {
entry_id: x.local_manifest.base.id,
need_sync: x.local_manifest.need_sync,
base_version: x.local_manifest.base.version,
Expand All @@ -345,7 +345,7 @@ pub(crate) async fn maybe_populate_workspace_storage(
if x.realm == realm_id && x.device == device.device_id =>
{
lazy_storage!()
.update_manifest(&UpdateManifestData {
.update_manifest(&ManifestData {
entry_id: x.local_manifest.base.id,
need_sync: x.local_manifest.need_sync,
base_version: x.local_manifest.base.version,
Expand Down
10 changes: 5 additions & 5 deletions libparsec/crates/platform_storage/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct WorkspaceStorage {
platform: PlatformWorkspaceStorage,
}

pub struct UpdateManifestData {
pub struct ManifestData {
pub entry_id: VlobID,
pub encrypted: RawEncryptedManifest,
pub need_sync: bool,
Expand Down Expand Up @@ -144,25 +144,25 @@ impl WorkspaceStorage {

pub async fn populate_manifest(
&mut self,
manifest: &UpdateManifestData,
manifest: &ManifestData,
) -> anyhow::Result<PopulateManifestOutcome> {
self.platform.populate_manifest(manifest).await
}

pub async fn update_manifest(&mut self, manifest: &UpdateManifestData) -> anyhow::Result<()> {
pub async fn update_manifest(&mut self, manifest: &ManifestData) -> anyhow::Result<()> {
self.platform.update_manifest(manifest).await
}

pub async fn update_manifests(
&mut self,
manifests: impl Iterator<Item = UpdateManifestData>,
manifests: impl Iterator<Item = ManifestData>,
) -> anyhow::Result<()> {
self.platform.update_manifests(manifests).await
}

pub async fn update_manifest_and_chunks(
&mut self,
manifest: &UpdateManifestData,
manifest: &ManifestData,
new_chunks: impl Iterator<Item = (ChunkID, Vec<u8>)>,
removed_chunks: impl Iterator<Item = ChunkID>,
) -> anyhow::Result<()> {
Expand Down
Loading

0 comments on commit 15f8ed7

Please sign in to comment.