Skip to content

Commit

Permalink
[WIP] Expose last updater.
Browse files Browse the repository at this point in the history
  • Loading branch information
AureliaDolo committed Nov 21, 2024
1 parent d110b02 commit c934930
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bindings/generator/api/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .common import (
U64,
DateTime,
DeviceID,
EntryName,
ErrorVariant,
FsPath,
Expand Down Expand Up @@ -316,6 +317,7 @@ class File:
is_placeholder: bool
need_sync: bool
size: SizeInt
last_updater: DeviceID

class Folder:
confinement_point: Optional[VlobID]
Expand All @@ -326,6 +328,7 @@ class Folder:
base_version: VersionInt
is_placeholder: bool
need_sync: bool
last_update: DeviceID


async def workspace_stat_entry(
Expand Down
4 changes: 4 additions & 0 deletions libparsec/crates/client/src/workspace/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ pub(super) fn merge_local_file_manifest(
need_sync: _,
// Ignore `updated`: we don't merge data that change on each sync
updated: _,
last_updater: _,
parent: local_parent,
size: local_size,
blocksize: local_blocksize,
Expand Down Expand Up @@ -275,6 +276,7 @@ pub(super) fn merge_local_folder_manifest(
local_confinement_points: _,
// Ignored, we don't merge data that change on each sync
updated: _,
last_updater: _,
} = local;

// 0) Sanity checks, caller is responsible to handle them properly !
Expand Down Expand Up @@ -370,12 +372,14 @@ pub(super) fn merge_local_folder_manifest(
updated: merged_updated,
children: merged_children,
speculative: merged_speculative,
last_updater: merged_last_updater,
} = &mut merge_in_progress;

*merged_speculative = false;
*merged_parent = local.parent;
*merged_need_sync = local.need_sync;
*merged_updated = local.updated;
*merged_last_updater = local.last_updater;
local.children.clone_into(merged_children);

return MergeLocalFolderManifestOutcome::Merged(Arc::new(merge_in_progress));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ async fn handle_conflict_and_update_store(
size,
blocksize,
blocks,
last_updater,
} = child_manifest.as_ref();

let mut conflicting =
Expand All @@ -462,6 +463,7 @@ async fn handle_conflict_and_update_store(
conflicting.updated = *updated;
conflicting.size = *size;
conflicting.blocksize = *blocksize;
conflicting.last_updater = *last_updater;
blocks.clone_into(&mut conflicting.blocks);

(child_manifest.base.id, Arc::new(conflicting))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl FolderReader {
base_version: self.manifest.base.version,
is_placeholder: self.manifest.base.version == 0,
need_sync: self.manifest.need_sync,
last_updater: self.manifest.last_updater,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub enum EntryStat {
is_placeholder: bool,
need_sync: bool,
size: SizeInt,
last_updater: DeviceID,
},
// Here Folder can also be the root of the workspace (i.e. WorkspaceManifest)
Folder {
Expand All @@ -40,6 +41,7 @@ pub enum EntryStat {
base_version: VersionInt,
is_placeholder: bool,
need_sync: bool,
last_updater: DeviceID,
},
}

Expand Down Expand Up @@ -145,6 +147,7 @@ pub(crate) async fn stat_entry_by_id(
base_version: manifest.base.version,
is_placeholder: manifest.base.version == 0,
need_sync: manifest.need_sync,
last_updater: manifest.last_updater,
},
ArcLocalChildManifest::File(manifest) => {
// If the file may be currently opened with un-flushed modifications.
Expand Down Expand Up @@ -174,6 +177,7 @@ pub(crate) async fn stat_entry_by_id(
is_placeholder: manifest.base.version == 0,
need_sync: manifest.need_sync,
size: manifest.size,
last_updater: manifest.last_updater,
}
}
};
Expand Down Expand Up @@ -216,6 +220,7 @@ pub(crate) async fn stat_entry(
base_version: manifest.base.version,
is_placeholder: manifest.base.version == 0,
need_sync: manifest.need_sync,
last_updater: manifest.last_updater,
},
ArcLocalChildManifest::File(manifest) => {
// If the file may be currently opened with un-flushed modifications.
Expand Down Expand Up @@ -245,6 +250,7 @@ pub(crate) async fn stat_entry(
is_placeholder: manifest.base.version == 0,
need_sync: manifest.need_sync,
size: manifest.size,
last_updater: manifest.last_updater,
}
}
};
Expand Down
4 changes: 4 additions & 0 deletions libparsec/crates/testbed/src/template/crc_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ impl CrcHash for LocalFolderManifest {
local_confinement_points,
remote_confinement_points,
speculative,
last_updater,
} = self;

base.crc_hash(hasher);
Expand All @@ -417,6 +418,7 @@ impl CrcHash for LocalFolderManifest {
local_confinement_points.crc_hash(hasher);
remote_confinement_points.crc_hash(hasher);
speculative.crc_hash(hasher);
last_updater.crc_hash(hasher);
}
}

Expand Down Expand Up @@ -501,6 +503,7 @@ impl CrcHash for LocalFileManifest {
size,
blocksize,
blocks,
last_updater,
} = self;

base.crc_hash(hasher);
Expand All @@ -510,6 +513,7 @@ impl CrcHash for LocalFileManifest {
size.crc_hash(hasher);
blocksize.crc_hash(hasher);
blocks.crc_hash(hasher);
last_updater.crc_hash(hasher);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"name": "updated",
"type": "DateTime"
},
{
"name": "last_updater",
"type": "DeviceID"
},
{
"name": "size",
"type": "Size"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"name": "updated",
"type": "DateTime"
},
{
"name": "last_updater",
"type": "DeviceID"
},
{
"name": "children",
"type": "Map<EntryName, VlobID>"
Expand Down
5 changes: 5 additions & 0 deletions libparsec/crates/types/src/local_manifest/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct LocalFileManifest {
pub parent: VlobID,
pub need_sync: bool,
pub updated: DateTime,
pub last_updater: DeviceID,
pub size: u64,
pub blocksize: Blocksize,
/// This field is named after the `FileManifest::blocks` field, however it
Expand Down Expand Up @@ -60,6 +61,7 @@ impl TryFrom<LocalFileManifestData> for LocalFileManifest {
size: data.size,
blocksize: data.blocksize.try_into()?,
blocks: data.blocks,
last_updater: data.last_updater,
})
}
}
Expand All @@ -75,6 +77,7 @@ impl From<LocalFileManifest> for LocalFileManifestData {
size: obj.size,
blocksize: obj.blocksize.into(),
blocks: obj.blocks,
last_updater: obj.last_updater,
}
}
}
Expand Down Expand Up @@ -102,6 +105,7 @@ impl LocalFileManifest {
blocksize: DEFAULT_BLOCK_SIZE,
size: 0,
blocks: vec![],
last_updater: author,
}
}

Expand Down Expand Up @@ -218,6 +222,7 @@ impl LocalFileManifest {
size: remote.size,
blocksize: remote.blocksize,
blocks,
last_updater: remote.author,
base: remote,
};

Expand Down
9 changes: 9 additions & 0 deletions libparsec/crates/types/src/local_manifest/folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct LocalFolderManifest {
pub parent: VlobID,
pub need_sync: bool,
pub updated: DateTime,
pub last_updater: DeviceID,
pub children: HashMap<EntryName, VlobID>,
// Confined entries are entries that are meant to stay locally and not be added
// to the uploaded remote manifest when synchronizing. The criteria for being
Expand Down Expand Up @@ -62,6 +63,7 @@ impl_transparent_data_format_conversion!(
local_confinement_points,
remote_confinement_points,
speculative,
last_updater
);

impl_local_manifest_dump!(LocalFolderManifest);
Expand All @@ -87,6 +89,7 @@ impl LocalFolderManifest {
local_confinement_points: HashSet::new(),
remote_confinement_points: HashSet::new(),
speculative: false,
last_updater: author,
}
}

Expand Down Expand Up @@ -156,6 +159,7 @@ impl LocalFolderManifest {
local_confinement_points: HashSet::new(),
remote_confinement_points: HashSet::new(),
speculative,
last_updater: author,
}
}

Expand Down Expand Up @@ -270,6 +274,7 @@ pub struct UnconfinedLocalFolderManifest {
pub updated: DateTime,
pub children: HashMap<EntryName, VlobID>,
pub speculative: bool,
pub last_updater: DeviceID,
}

impl UnconfinedLocalFolderManifest {
Expand All @@ -280,6 +285,7 @@ impl UnconfinedLocalFolderManifest {
updated: remote.updated,
children: remote.children.clone(),
speculative: false,
last_updater: remote.author,
base: remote,
}
}
Expand Down Expand Up @@ -327,6 +333,7 @@ impl UnconfinedLocalFolderManifest {
local_confinement_points: HashSet::new(),
remote_confinement_points,
speculative: false,
last_updater: remote.author,
base: remote,
}
}
Expand Down Expand Up @@ -390,6 +397,7 @@ impl UnconfinedLocalFolderManifest {
local_confinement_points,
remote_confinement_points,
speculative: self.speculative,
last_updater: self.last_updater,
};

// Check whether there are existing local confinement entries to restore
Expand Down Expand Up @@ -463,6 +471,7 @@ impl UnconfinedLocalFolderManifest {
updated: local_manifest.updated,
children: new_children,
speculative: local_manifest.speculative,
last_updater: local_manifest.last_updater,
}
}
}

0 comments on commit c934930

Please sign in to comment.