mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-03 16:41:26 +01:00
fixed a migration bug where ProtonDrive becomse unwritable
This commit is contained in:
1 parent
77198ed261
commit
9bbd8eb982
4 files changed
+65
-9
No files matched your search
@@ -992,7 +992,15 @@ impl ProtonFs {
|
||||
warn!(uid = %root.uid, error = %e, "db upsert root failed");
|
||||
}
|
||||
st.by_uid.insert(root.uid.clone(), ROOT_INO);
|
||||
let access = st.access_for_node(ROOT_INO, &root);
|
||||
// The filesystem root is always owned — it must never be
|
||||
// classified as a shared root, even when the API returns
|
||||
// membership data (which happens when the owner shares the
|
||||
// folder with someone else). Clean up any stale share_access
|
||||
// row that a previous downgrade_all_share_access may have
|
||||
// written for this uid, so hydrate_access cannot pick it up.
|
||||
let access = Access::Owner;
|
||||
st.share_access.remove(&root.uid);
|
||||
let _ = st.db.delete_share_access(&root.uid);
|
||||
st.entries.insert(
|
||||
ROOT_INO,
|
||||
Entry {
|
||||
|
||||
@@ -448,8 +448,13 @@ impl State {
|
||||
let roots: Vec<u64> = self
|
||||
.entries
|
||||
.iter()
|
||||
.filter(|entry| {
|
||||
let (_, entry) = entry;
|
||||
.filter(|&(&ino, entry)| {
|
||||
// The filesystem root (parent == self) is always owned; never
|
||||
// downgrade it even if it carries membership from the owner
|
||||
// sharing this folder with someone else.
|
||||
if entry.parent == ino {
|
||||
return false;
|
||||
}
|
||||
entry.access != Access::Owner
|
||||
|| entry.node.membership.is_some()
|
||||
|| self.share_access.contains_key(&entry.uid)
|
||||
@@ -494,10 +499,12 @@ impl State {
|
||||
return Access::Unknown;
|
||||
}
|
||||
let stored = state.share_access.get(&entry.uid).copied();
|
||||
let access = if let Some(stored) = stored {
|
||||
stored
|
||||
} else if entry.parent == ino {
|
||||
// The root of this mount is always owned, regardless of any
|
||||
// stale share_access row that a global downgrade may have left.
|
||||
let access = if entry.parent == ino {
|
||||
Access::Owner
|
||||
} else if let Some(stored) = stored {
|
||||
stored
|
||||
} else if !state.entries.contains_key(&entry.parent) {
|
||||
entry
|
||||
.node
|
||||
@@ -538,8 +545,12 @@ impl State {
|
||||
}
|
||||
let discovered: Vec<(NodeUid, Access)> = self
|
||||
.entries
|
||||
.values()
|
||||
.filter_map(|entry| {
|
||||
.iter()
|
||||
.filter_map(|(&ino, entry)| {
|
||||
// The filesystem root is owned, not a discovered share root.
|
||||
if entry.parent == ino {
|
||||
return None;
|
||||
}
|
||||
let parent_access = self
|
||||
.entries
|
||||
.get(&entry.parent)
|
||||
|
||||
Reference in new issue
Block a user