Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libparsec] Expose last updater. #8974

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
last_update: DeviceID
last_updater: DeviceID



async def workspace_stat_entry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ async fn handle_conflict_and_update_store(
)),
};

// 2) Local changes causing the conflict are transfered to a new manifest
// 2) Local changes causing the conflict are transferred to a new manifest

let (original_child_id, conflicting_new_child_manifest) = match local_child_manifest {
// Most likely case since file content cannot be merged
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.base.author,
}
}

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.base.author,
},
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.base.author,
}
}
};
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.base.author,
},
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.base.author,
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,7 @@ async fn local_and_remote_changes(
expected.parent = local.base.id;
expected.base.parent = local.base.id;


let local_child_id = VlobID::from_hex("a1d7229d7e44418a8a4e4fd821003fd3").unwrap();
let remote_child_id = VlobID::from_hex("9a20331879744a149f55bc3ba16e8225").unwrap();

Expand Down Expand Up @@ -2237,8 +2238,7 @@ async fn local_and_remote_changes(
local.need_sync = false;
// ...the remote hasn't anything important to merge, but this should
// refresh the confinement in local with the new prevent sync pattern.
remote.author = local_author;

remote.author = local_author;
// Given the remote is from ourself, the merge considers we already know
// about it and hence acknowledges it and preserve the local children.
// However the new prevent sync pattern means the local child is now
Expand Down
12 changes: 12 additions & 0 deletions libparsec/crates/client/tests/unit/workspace/read_folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ async fn ok_with_local_cache(#[values(true, false)] target_is_root: bool, env: &
is_placeholder: false,
need_sync: false,
size: 11,
last_updater: alice.device_id,
},
),
(
Expand All @@ -64,6 +65,7 @@ async fn ok_with_local_cache(#[values(true, false)] target_is_root: bool, env: &
base_version: 1,
is_placeholder: false,
need_sync: false,
last_updater: alice.device_id,
},
),
];
Expand All @@ -84,6 +86,7 @@ async fn ok_with_local_cache(#[values(true, false)] target_is_root: bool, env: &
is_placeholder: false,
need_sync: false,
size: 0,
last_updater: alice.device_id,
},
),
(
Expand All @@ -97,6 +100,7 @@ async fn ok_with_local_cache(#[values(true, false)] target_is_root: bool, env: &
base_version: 1,
is_placeholder: false,
need_sync: false,
last_updater: alice.device_id,
},
),
];
Expand Down Expand Up @@ -200,6 +204,7 @@ async fn ok_no_local_cache(#[values(true, false)] target_is_root: bool, env: &Te
is_placeholder: false,
need_sync: false,
size: 11,
last_updater: alice.device_id,
},
),
(
Expand All @@ -213,6 +218,7 @@ async fn ok_no_local_cache(#[values(true, false)] target_is_root: bool, env: &Te
base_version: 1,
is_placeholder: false,
need_sync: false,
last_updater: alice.device_id,
},
),
];
Expand All @@ -233,6 +239,7 @@ async fn ok_no_local_cache(#[values(true, false)] target_is_root: bool, env: &Te
is_placeholder: false,
need_sync: false,
size: 0,
last_updater: alice.device_id,
},
),
(
Expand All @@ -246,6 +253,7 @@ async fn ok_no_local_cache(#[values(true, false)] target_is_root: bool, env: &Te
base_version: 1,
is_placeholder: false,
need_sync: false,
last_updater: alice.device_id,
},
),
];
Expand Down Expand Up @@ -435,6 +443,7 @@ async fn read_folder_with_confined_entries(
is_placeholder: false,
need_sync: false,
size: 0,
last_updater: alice.device_id,
},
),
(
Expand All @@ -448,6 +457,7 @@ async fn read_folder_with_confined_entries(
base_version: 1,
is_placeholder: false,
need_sync: false,
last_updater: alice.device_id,
},
),
];
Expand Down Expand Up @@ -572,6 +582,7 @@ async fn read_folder_containing_under_modification_file(
is_placeholder: false,
need_sync: true,
size: expected_size,
last_updater: alice.device_id,
},
),
(
Expand All @@ -585,6 +596,7 @@ async fn read_folder_containing_under_modification_file(
base_version: 1,
is_placeholder: false,
need_sync: false,
last_updater: alice.device_id,
},
),
];
Expand Down
28 changes: 22 additions & 6 deletions libparsec/crates/client/tests/unit/workspace/stat_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async fn stat_entry(#[values(true, false)] local_cache: bool, env: &TestbedEnv)
updated,
base_version,
is_placeholder,
need_sync,
need_sync,last_updater
}
if {
p_assert_eq!(confinement_point, None);
Expand All @@ -58,6 +58,8 @@ async fn stat_entry(#[values(true, false)] local_cache: bool, env: &TestbedEnv)
p_assert_eq!(base_version, 1);
p_assert_eq!(is_placeholder, false);
p_assert_eq!(need_sync, false);

p_assert_eq!(last_updater, alice.device_id);
true
}
);
Expand All @@ -75,7 +77,7 @@ async fn stat_entry(#[values(true, false)] local_cache: bool, env: &TestbedEnv)
updated,
base_version,
is_placeholder,
need_sync,
need_sync,last_updater
}
if {
p_assert_eq!(confinement_point, None);
Expand All @@ -86,6 +88,8 @@ async fn stat_entry(#[values(true, false)] local_cache: bool, env: &TestbedEnv)
p_assert_eq!(base_version, 1);
p_assert_eq!(is_placeholder, false);
p_assert_eq!(need_sync, false);
p_assert_eq!(last_updater, alice.device_id);

true
}
);
Expand All @@ -104,7 +108,7 @@ async fn stat_entry(#[values(true, false)] local_cache: bool, env: &TestbedEnv)
base_version,
is_placeholder,
need_sync,
size,
size,last_updater
}
if {
p_assert_eq!(confinement_point, None);
Expand All @@ -116,6 +120,8 @@ async fn stat_entry(#[values(true, false)] local_cache: bool, env: &TestbedEnv)
p_assert_eq!(is_placeholder, false);
p_assert_eq!(need_sync, false);
p_assert_eq!(size, 11); // Contains "hello world"
p_assert_eq!(last_updater, alice.device_id);

true
}
);
Expand Down Expand Up @@ -206,7 +212,7 @@ async fn stat_entry_by_id(
updated,
base_version,
is_placeholder,
need_sync,
need_sync,last_updater
}
if {
p_assert_eq!(confinement_point, expected_confinement_point);
Expand All @@ -217,6 +223,8 @@ async fn stat_entry_by_id(
p_assert_eq!(base_version, 1);
p_assert_eq!(is_placeholder, false);
p_assert_eq!(need_sync, false);
p_assert_eq!(last_updater, alice.device_id);

true
}
);
Expand All @@ -235,7 +243,7 @@ async fn stat_entry_by_id(
updated,
base_version,
is_placeholder,
need_sync,
need_sync, last_updater
}
if {
p_assert_eq!(confinement_point, expected_confinement_point);
Expand All @@ -246,6 +254,8 @@ async fn stat_entry_by_id(
p_assert_eq!(base_version, 1);
p_assert_eq!(is_placeholder, false);
p_assert_eq!(need_sync, false);
p_assert_eq!(last_updater, alice.device_id);

true
}
);
Expand All @@ -264,7 +274,7 @@ async fn stat_entry_by_id(
base_version,
is_placeholder,
need_sync,
size,
size,last_updater
}
if {
p_assert_eq!(confinement_point, expected_confinement_point);
Expand All @@ -276,6 +286,8 @@ async fn stat_entry_by_id(
p_assert_eq!(is_placeholder, false);
p_assert_eq!(need_sync, false);
p_assert_eq!(size, 11); // Contains "hello world"
p_assert_eq!(last_updater, alice.device_id);

true
}
);
Expand Down Expand Up @@ -319,6 +331,7 @@ async fn stat_entry_on_speculative_workspace(env: &TestbedEnv) {
base_version,
is_placeholder,
need_sync,
last_updater,
} if {
p_assert_eq!(confinement_point, None);
p_assert_eq!(id, wksp1_id);
Expand All @@ -328,6 +341,8 @@ async fn stat_entry_on_speculative_workspace(env: &TestbedEnv) {
p_assert_eq!(base_version, 0);
p_assert_eq!(is_placeholder, true);
p_assert_eq!(need_sync, true);
p_assert_eq!(last_updater, alice.device_id);

true
}
);
Expand Down Expand Up @@ -606,6 +621,7 @@ async fn stat_entry_on_under_modification_file(
is_placeholder: false,
need_sync: true,
size: expected_size,
last_updater: alice.device_id,
};

p_assert_eq!(stat, expected_stat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ async fn parent_doesnt_exist(tmp_path: TmpPath, env: &TestbedEnv) {
base_version: 0,
is_placeholder: false,
need_sync: false,
last_updater: "alice@dev1".parse().unwrap(),
}))
} else {
// Fallback to real lookup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ async fn no_create_and_not_found(tmp_path: TmpPath, env: &TestbedEnv) {
is_placeholder: false,
need_sync: false,
size: 0,
last_updater: "alice@dev1".parse().unwrap(),
}))
} else {
// Fallback to real lookup
Expand Down
Loading
Loading