mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-29 04:22:13 +01:00
Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2882f17ade | ||
|
|
1ab759ebcc | ||
|
|
9667b7daca | ||
|
|
e2e8d3ad75 | ||
|
|
d5bcba5aa7 | ||
|
|
4913178532 | ||
|
|
1bd3d1577a | ||
|
|
cf09850c17 | ||
|
|
8ee457cbcf | ||
|
|
d03c96e0c8 | ||
|
|
a0c51d87fb | ||
|
|
cf2632a1b5 | ||
|
|
af033f33a4 | ||
|
|
e3f371eb5d | ||
|
|
d025e53933 | ||
|
|
65d17fd3a7 |
No files matched your search
Generated
+10
-10
@@ -3634,7 +3634,7 @@ checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
|
||||
|
||||
[[package]]
|
||||
name = "pdfs-cli"
|
||||
version = "3.10.0"
|
||||
version = "4.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@@ -3653,7 +3653,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pdfs-core"
|
||||
version = "3.10.0"
|
||||
version = "4.0.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.23.1",
|
||||
@@ -3683,7 +3683,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pdfs-daemon"
|
||||
version = "3.10.0"
|
||||
version = "4.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"pdfs-core",
|
||||
@@ -3695,7 +3695,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pdfs-drive"
|
||||
version = "3.10.0"
|
||||
version = "4.0.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures",
|
||||
@@ -3710,7 +3710,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pdfs-fuse"
|
||||
version = "3.10.0"
|
||||
version = "4.0.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.23.1",
|
||||
@@ -3748,7 +3748,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pdfs-gui"
|
||||
version = "3.10.0"
|
||||
version = "4.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-channel",
|
||||
@@ -3773,7 +3773,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pdfs-sched"
|
||||
version = "3.10.0"
|
||||
version = "4.0.0"
|
||||
dependencies = [
|
||||
"parking_lot 0.13.0",
|
||||
"tokio",
|
||||
@@ -3781,7 +3781,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pdfs-store"
|
||||
version = "3.10.0"
|
||||
version = "4.0.0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"parking_lot 0.13.0",
|
||||
@@ -3797,7 +3797,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pdfs-sync"
|
||||
version = "3.10.0"
|
||||
version = "4.0.0"
|
||||
dependencies = [
|
||||
"notify",
|
||||
"parking_lot 0.13.0",
|
||||
@@ -3813,7 +3813,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pdfs-vfs"
|
||||
version = "3.10.0"
|
||||
version = "4.0.0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"parking_lot 0.13.0",
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ resolver = "2"
|
||||
members = ["crates/pdfs-core", "crates/pdfs-store", "crates/pdfs-drive", "crates/pdfs-sync", "crates/pdfs-sched", "crates/pdfs-vfs", "crates/pdfs-fuse", "crates/pdfs-daemon", "crates/pdfs-cli", "crates/pdfs-gui"]
|
||||
|
||||
[workspace.package]
|
||||
version = "3.10.0"
|
||||
version = "4.0.0"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["Nils Pukropp <contact@narl.io>"]
|
||||
|
||||
@@ -289,6 +289,29 @@ pub(super) fn admission_line(load: &pdfs_core::control::AdmissionLoad) -> String
|
||||
line
|
||||
}
|
||||
|
||||
/// One mirror effect not settled yet in `pdfs diagnostics`:
|
||||
/// `folder 3 upload docs/a.txt: retry, sent 2 times, 5m0s ago (timed out)`.
|
||||
pub(super) fn effect_line(intent: &pdfs_core::control::EffectIntent) -> String {
|
||||
let times = if intent.attempts == 1 {
|
||||
"time"
|
||||
} else {
|
||||
"times"
|
||||
};
|
||||
let mut line = format!(
|
||||
"folder {} {} {}: {}, sent {} {times}, {} ago",
|
||||
intent.folder_id,
|
||||
intent.kind,
|
||||
intent.rel_path,
|
||||
intent.state,
|
||||
intent.attempts,
|
||||
human_secs(intent.age_secs),
|
||||
);
|
||||
if let Some(error) = &intent.last_error {
|
||||
line.push_str(&format!(" ({error})"));
|
||||
}
|
||||
line
|
||||
}
|
||||
|
||||
/// A wait, in ms below a second, where most admission waits fall.
|
||||
fn wait_ms(ms: u64) -> String {
|
||||
if ms < 1000 {
|
||||
@@ -398,6 +421,19 @@ pub(super) fn cmd_diagnostics() -> Result<()> {
|
||||
);
|
||||
}
|
||||
}
|
||||
match &d.effects {
|
||||
None => {}
|
||||
Some(effects) if effects.count == 0 => println!("sync effects not settled: none"),
|
||||
Some(effects) => {
|
||||
println!("sync effects not settled: {} (oldest first)", effects.count);
|
||||
for intent in &effects.oldest {
|
||||
println!(" {}", effect_line(intent));
|
||||
}
|
||||
if effects.count > effects.oldest.len() {
|
||||
println!(" and {} more", effects.count - effects.oldest.len());
|
||||
}
|
||||
}
|
||||
}
|
||||
if d.inflight.is_empty() {
|
||||
println!("in-flight requests: none");
|
||||
} else {
|
||||
@@ -526,9 +562,36 @@ pub(super) fn cmd_cache_inspect(deep: bool) -> Result<()> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use pdfs_core::control::AdmissionLoad;
|
||||
use pdfs_core::control::{AdmissionLoad, EffectIntent};
|
||||
|
||||
use super::admission_line;
|
||||
use super::{admission_line, effect_line};
|
||||
|
||||
#[test]
|
||||
fn an_effect_line_says_what_waits_and_why() {
|
||||
let intent = EffectIntent {
|
||||
folder_id: 3,
|
||||
rel_path: "docs/a.txt".into(),
|
||||
kind: "upload".into(),
|
||||
state: "retry".into(),
|
||||
attempts: 2,
|
||||
age_secs: 300,
|
||||
last_error: Some("timed out".into()),
|
||||
};
|
||||
assert_eq!(
|
||||
effect_line(&intent),
|
||||
"folder 3 upload docs/a.txt: retry, sent 2 times, 5m0s ago (timed out)"
|
||||
);
|
||||
let sent = EffectIntent {
|
||||
state: "issued".into(),
|
||||
attempts: 1,
|
||||
last_error: None,
|
||||
..intent
|
||||
};
|
||||
assert_eq!(
|
||||
effect_line(&sent),
|
||||
"folder 3 upload docs/a.txt: issued, sent 1 time, 5m0s ago"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_admission_line_says_who_waits_and_for_how_long() {
|
||||
|
||||
@@ -2400,6 +2400,41 @@ pub struct Diagnostics {
|
||||
/// Empty from a daemon that predates the field.
|
||||
#[serde(default)]
|
||||
pub admission: Vec<AdmissionLoad>,
|
||||
/// The mirror effects not settled yet: sent and waiting for an answer,
|
||||
/// left unsure by a stop, or failed. `None` when the database did not
|
||||
/// answer in time, or from a daemon that predates the field.
|
||||
#[serde(default)]
|
||||
pub effects: Option<EffectReport>,
|
||||
}
|
||||
|
||||
/// The mirror effects not settled yet, in [`Diagnostics::effects`].
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub struct EffectReport {
|
||||
/// How many there are.
|
||||
pub count: usize,
|
||||
/// The oldest of them, at most [`EffectReport::SHOWN`].
|
||||
pub oldest: Vec<EffectIntent>,
|
||||
}
|
||||
|
||||
impl EffectReport {
|
||||
/// How many effects a report lists.
|
||||
pub const SHOWN: usize = 20;
|
||||
}
|
||||
|
||||
/// One mirror effect not settled yet, in [`EffectReport::oldest`].
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub struct EffectIntent {
|
||||
pub folder_id: i64,
|
||||
pub rel_path: String,
|
||||
/// What it does, such as `upload`, `download` or `trash`.
|
||||
pub kind: String,
|
||||
/// `issued`, `unsure`, `retry` or `blocked`.
|
||||
pub state: String,
|
||||
/// How many times it was sent.
|
||||
pub attempts: u32,
|
||||
/// How long ago it was last sent.
|
||||
pub age_secs: u64,
|
||||
pub last_error: Option<String>,
|
||||
}
|
||||
|
||||
/// One class of background step in the daemon's admission, in
|
||||
|
||||
@@ -16,6 +16,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use pdfs_core::config::AppDirs;
|
||||
use pdfs_core::control::ErrorKind;
|
||||
use pdfs_core::control::{
|
||||
ActivityKind, Event, HEARTBEAT, PhotoMonth, RefreshScope, Request as CtlRequest,
|
||||
Response as CtlResponse, Topic, TransferDirection, TrashFailure,
|
||||
@@ -647,8 +648,23 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
||||
},
|
||||
Err(e) => CtlResponse::error(e),
|
||||
},
|
||||
Ok(CtlRequest::Unpin { path }) => match route_keep(core, mountpoint, &path) {
|
||||
Ok((routed, rel)) => match routed.unpin(&rel) {
|
||||
Ok(CtlRequest::Unpin { path }) => {
|
||||
let unpinned = route_keep(core, mountpoint, &path)
|
||||
.and_then(|(routed, rel)| routed.unpin(&rel))
|
||||
.or_else(|e| match e.kind {
|
||||
// The node is gone, and its pin with it unless the pin
|
||||
// was left behind; drop that one by the path it is listed
|
||||
// under.
|
||||
ErrorKind::NotFound => match core.unpin_stale(&path) {
|
||||
Ok(true) => Ok(Path::new(&path)
|
||||
.file_name()
|
||||
.map_or_else(|| path.clone(), |n| n.to_string_lossy().into_owned())),
|
||||
Ok(false) => Err(e),
|
||||
Err(stale) => Err(stale),
|
||||
},
|
||||
_ => Err(e),
|
||||
});
|
||||
match unpinned {
|
||||
Ok(name) => {
|
||||
core.profile().touch_profile();
|
||||
CtlResponse::Ok {
|
||||
@@ -656,9 +672,8 @@ fn handle_control_conn(core: &Core, username: &str, mountpoint: &Path, stream: U
|
||||
}
|
||||
}
|
||||
Err(e) => CtlResponse::error(e),
|
||||
},
|
||||
Err(e) => CtlResponse::error(e),
|
||||
},
|
||||
}
|
||||
}
|
||||
Ok(CtlRequest::ListPins) => CtlResponse::Pins {
|
||||
pins: core.list_pins(),
|
||||
},
|
||||
|
||||
@@ -9,12 +9,13 @@
|
||||
use std::path::Path;
|
||||
|
||||
use pdfs_core::CoreResult;
|
||||
use pdfs_core::control::ErrorKind;
|
||||
use pdfs_core::control::{ActivityKind, Request as CtlRequest, Response as CtlResponse};
|
||||
use proton_drive_rs::proton_sdk::ids::NodeUid;
|
||||
|
||||
use super::rel_to_mount;
|
||||
use crate::Core;
|
||||
use crate::sharing::StopSharingOutcome;
|
||||
use crate::{Core, parse_uid};
|
||||
|
||||
/// The requests [`answer`] serves, as a pattern, so the control socket's
|
||||
/// match hands exactly these over and the compiler still checks that it covers
|
||||
@@ -73,13 +74,22 @@ impl Target {
|
||||
})
|
||||
}
|
||||
|
||||
/// A node named by its uid, which one of this daemon's locations, or the
|
||||
/// Photos timeline, must show to be this account's.
|
||||
/// A node named by its uid, which one of this daemon's locations, the
|
||||
/// Photos timeline, or Drive's list of what this account shared must show
|
||||
/// to be this account's. The last covers a node shared from elsewhere and
|
||||
/// never browsed to here: Shared by me lists it, and without it the share
|
||||
/// could not be managed, nor stopped, from this computer.
|
||||
fn uid(core: &Core, uid: String) -> Self {
|
||||
Self {
|
||||
node: core.resolve_shareable(&uid),
|
||||
label: uid,
|
||||
}
|
||||
let node = core.resolve_shareable(&uid).or_else(|e| {
|
||||
if e.kind != ErrorKind::NotFound {
|
||||
return Err(e);
|
||||
}
|
||||
match parse_uid(&uid) {
|
||||
Some(node) if core.sharing.shared_by_me(&node)? => Ok(node),
|
||||
_ => Err(e),
|
||||
}
|
||||
});
|
||||
Self { node, label: uid }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,13 @@ use std::time::{Duration, Instant};
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use pdfs_core::control::{
|
||||
AdmissionLoad, Diagnostics, DriveCallStat, InflightRequest, ServiceState, UploadPathStat,
|
||||
WorkerState,
|
||||
AdmissionLoad, Diagnostics, DriveCallStat, EffectIntent, EffectReport, InflightRequest,
|
||||
ServiceState, UploadPathStat, WorkerState,
|
||||
};
|
||||
|
||||
use pdfs_core::lifecycle::ServiceBoard;
|
||||
use pdfs_core::timestamp::now_secs;
|
||||
use pdfs_store::db::StoredIntent;
|
||||
|
||||
use super::Core;
|
||||
|
||||
@@ -146,6 +148,7 @@ impl Core {
|
||||
})
|
||||
.unwrap_or_default();
|
||||
inflight.sort_by_key(|request| std::cmp::Reverse(request.age_secs));
|
||||
let (pending_ops, effects) = self.database_quickly().unzip();
|
||||
|
||||
Diagnostics {
|
||||
uptime_secs: STARTED.elapsed().as_secs(),
|
||||
@@ -167,7 +170,8 @@ impl Core {
|
||||
inflight,
|
||||
control_handlers: super::control::active_handlers(),
|
||||
control_handler_limit: super::control::handler_limit(),
|
||||
pending_ops: self.pending_ops_quickly(),
|
||||
pending_ops,
|
||||
effects,
|
||||
sync: Some(self.sync.engine.report()),
|
||||
services: self
|
||||
.services
|
||||
@@ -230,26 +234,50 @@ impl Core {
|
||||
}
|
||||
}
|
||||
|
||||
/// Queued mutations, or `None` when the database did not answer within
|
||||
/// [`PENDING_COUNT_DEADLINE`] or an earlier probe is still waiting on it.
|
||||
/// Queued mutations and the mirror effects not settled yet, or `None`
|
||||
/// when the database did not answer within [`DATABASE_DEADLINE`] or an
|
||||
/// earlier probe is still waiting on it.
|
||||
///
|
||||
/// The supervisor asks for a report every tick. One thread per report
|
||||
/// would pile up behind a database that never answers, so a second probe
|
||||
/// is not started until the first one has returned.
|
||||
fn pending_ops_quickly(&self) -> Option<u64> {
|
||||
fn database_quickly(&self) -> Option<(u64, EffectReport)> {
|
||||
let db = self.db.clone();
|
||||
probe_once(
|
||||
&self.services,
|
||||
&self.pending_probe,
|
||||
PENDING_COUNT_DEADLINE,
|
||||
DATABASE_DEADLINE,
|
||||
move || {
|
||||
let counts = db.pending_op_counts().ok()?;
|
||||
Some(counts.uploads.max(0) as u64 + counts.changes.max(0) as u64)
|
||||
let pending = counts.uploads.max(0) as u64 + counts.changes.max(0) as u64;
|
||||
let intents = db.sync_intents(None).ok()?;
|
||||
Some((pending, effect_report(intents, now_secs())))
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// The report of the unsettled `intents`, oldest first, at `now`.
|
||||
fn effect_report(mut intents: Vec<StoredIntent>, now: i64) -> EffectReport {
|
||||
intents.sort_by_key(|intent| (intent.issued_at, intent.id));
|
||||
EffectReport {
|
||||
count: intents.len(),
|
||||
oldest: intents
|
||||
.into_iter()
|
||||
.take(EffectReport::SHOWN)
|
||||
.map(|intent| EffectIntent {
|
||||
folder_id: intent.folder_id,
|
||||
rel_path: intent.rel_path,
|
||||
kind: intent.kind,
|
||||
state: intent.state,
|
||||
attempts: intent.attempts,
|
||||
age_secs: u64::try_from(now - intent.issued_at).unwrap_or(0),
|
||||
last_error: intent.last_error,
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
fn millis(took: Duration) -> u64 {
|
||||
u64::try_from(took.as_millis()).unwrap_or(u64::MAX)
|
||||
}
|
||||
@@ -282,12 +310,49 @@ fn probe_once<T: Send + 'static>(
|
||||
}
|
||||
|
||||
/// How long the report waits for the database before reporting without it.
|
||||
const PENDING_COUNT_DEADLINE: Duration = Duration::from_millis(500);
|
||||
const DATABASE_DEADLINE: Duration = Duration::from_millis(500);
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// The report counts every unsettled effect but lists only the oldest,
|
||||
/// so a folder with thousands of failed uploads stays readable.
|
||||
#[test]
|
||||
fn the_effect_report_lists_the_oldest_and_counts_them_all() {
|
||||
let intent = |id: i64, issued_at: i64| StoredIntent {
|
||||
id,
|
||||
folder_id: 1,
|
||||
rel_path: format!("f{id}"),
|
||||
kind: "trash".into(),
|
||||
state: "retry".into(),
|
||||
attempts: 2,
|
||||
issued_at,
|
||||
last_error: Some("offline".into()),
|
||||
sent_sha1s: Vec::new(),
|
||||
};
|
||||
let total = EffectReport::SHOWN as i64 + 5;
|
||||
let intents = (0..total).map(|id| intent(id, 1_000 - id)).collect();
|
||||
let report = effect_report(intents, 1_100);
|
||||
assert_eq!(report.count, total as usize);
|
||||
assert_eq!(report.oldest.len(), EffectReport::SHOWN);
|
||||
let first = &report.oldest[0];
|
||||
assert_eq!(first.rel_path, format!("f{}", total - 1));
|
||||
assert_eq!(first.age_secs, 100 + total as u64 - 1);
|
||||
assert_eq!(first.last_error.as_deref(), Some("offline"));
|
||||
assert!(
|
||||
report
|
||||
.oldest
|
||||
.windows(2)
|
||||
.all(|pair| pair[0].age_secs >= pair[1].age_secs)
|
||||
);
|
||||
// A clock that went back reads as just sent, not as a wrap.
|
||||
assert_eq!(
|
||||
effect_report(vec![intent(1, 2_000)], 1_000).oldest[0].age_secs,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
/// The request name is read off the wire format, so it must match both
|
||||
/// shapes serde produces.
|
||||
#[test]
|
||||
|
||||
@@ -627,6 +627,12 @@ impl Core {
|
||||
.db
|
||||
.has_pending_op(&uid.to_string(), OP_RENAME)
|
||||
.unwrap_or(false);
|
||||
// A write queued since the check above has stamped its size on the
|
||||
// tree already, and the node read back must not put the landed size
|
||||
// back over it. Listings do the same (B308).
|
||||
let mut landed = [node.clone()];
|
||||
self.stamp_pending_sizes(&mut landed);
|
||||
let [node] = landed;
|
||||
self.for_each_state(|st| {
|
||||
let moved = placed_in(st, uid) != before;
|
||||
let Some(entry) = st.by_uid.get(uid).and_then(|ino| st.entries.get(ino)) else {
|
||||
|
||||
@@ -194,6 +194,22 @@ impl Core {
|
||||
Ok(name)
|
||||
}
|
||||
|
||||
/// Drop the pins recorded under `path`, the path a front end lists a pin
|
||||
/// by, when their node is gone. A deleted node leaves no path to resolve,
|
||||
/// so [`unpin`](Self::unpin) cannot find it, and the pin would stay listed
|
||||
/// as kept offline for good. Returns whether any pin was dropped.
|
||||
pub(super) fn unpin_stale(&self, path: &str) -> CoreResult<bool> {
|
||||
let uids = self
|
||||
.cache
|
||||
.remove_pins_at(path)
|
||||
.map_err(|e| CoreError::from_api(&e, "unpin"))?;
|
||||
for uid in uids.iter().filter_map(|s| parse_uid(s)) {
|
||||
self.cache.evict(&uid);
|
||||
self.evict_reader(&uid);
|
||||
}
|
||||
Ok(!uids.is_empty())
|
||||
}
|
||||
|
||||
/// Whether the node at `ino` is kept offline because a folder above it is
|
||||
/// pinned, whether or not it is also pinned on its own.
|
||||
pub(super) fn pinned_by_folder(&self, ino: u64) -> bool {
|
||||
|
||||
@@ -645,6 +645,17 @@ impl Sharing {
|
||||
Ok(items)
|
||||
}
|
||||
|
||||
/// Whether Drive lists `uid` among the nodes this account shared. That list
|
||||
/// is the account's own word that the node is its share, so it stands in
|
||||
/// for the residency proof a node never browsed to cannot give.
|
||||
pub(crate) fn shared_by_me(&self, uid: &NodeUid) -> CoreResult<bool> {
|
||||
let uids = self
|
||||
.rt
|
||||
.block_on(self.client.enumerate_shared_by_me_node_uids())
|
||||
.map_err(|e| CoreError::from_api(&e, "enumerate shared-by-me"))?;
|
||||
Ok(uids.contains(uid))
|
||||
}
|
||||
|
||||
/// Best-effort mountpoint-relative path for a node already interned in the live
|
||||
/// tree, by walking parent inodes to the root. `None` when the node has never
|
||||
/// been seen through the mount (e.g. shared but not browsed to this session) —
|
||||
|
||||
@@ -2196,6 +2196,64 @@ mod tests {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// The mirror effects not settled yet, from `pdfs diagnostics`.
|
||||
fn effects(daemon: &Daemon) -> Vec<control::EffectIntent> {
|
||||
let Ok(Response::Diagnostics { diagnostics }) = daemon.request(&Request::Diagnostics)
|
||||
else {
|
||||
panic!("no diagnostics");
|
||||
};
|
||||
diagnostics.effects.map(|e| e.oldest).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// A deletion a mirror pass sends is recorded like any other effect, and
|
||||
/// `pdfs diagnostics` lists it until it lands: a trash on Drive while its
|
||||
/// answer is outstanding, and a removal from disk.
|
||||
#[test]
|
||||
#[ignore = "mounts FUSE: run with `cargo test -p pdfs-fuse sim:: -- --ignored`"]
|
||||
fn a_deletion_is_an_effect_until_it_lands() {
|
||||
let drive = FakeDrive::new();
|
||||
let dir = scratch("deletion-effect");
|
||||
let (daemon, folder, _client) = start_mirror(
|
||||
&drive,
|
||||
&dir,
|
||||
&[
|
||||
("a.txt", b"one"),
|
||||
("b.txt", b"two"),
|
||||
("c.txt", b"three"),
|
||||
("d.txt", b"four"),
|
||||
],
|
||||
);
|
||||
quiet_pass(&daemon, folder).expect("a quiet pass is traced");
|
||||
let uid = drive.lookup("mirrored/a.txt").unwrap();
|
||||
let held = daemon.client.hold_next_trash(&uid);
|
||||
std::fs::remove_file(dir.join("local").join("a.txt")).unwrap();
|
||||
assert!(wait_until(Duration::from_secs(60), || held.reached()));
|
||||
let listed = effects(&daemon);
|
||||
assert!(
|
||||
listed.iter().any(|e| e.folder_id == folder
|
||||
&& e.rel_path == "a.txt"
|
||||
&& e.kind == "trash"
|
||||
&& e.state == "issued"),
|
||||
"{listed:#?}"
|
||||
);
|
||||
drop(held);
|
||||
assert!(wait_until(Duration::from_secs(60), || {
|
||||
drive.lookup("mirrored/a.txt").is_none() && effects(&daemon).is_empty()
|
||||
}));
|
||||
|
||||
drive.device().trash("mirrored/b.txt");
|
||||
assert!(wait_until(Duration::from_secs(60), || {
|
||||
!dir.join("local").join("b.txt").exists()
|
||||
}));
|
||||
assert!(
|
||||
wait_until(Duration::from_secs(30), || effects(&daemon).is_empty()),
|
||||
"{:#?}",
|
||||
effects(&daemon)
|
||||
);
|
||||
assert!(matches!(daemon.stop(), Ok(MountOutcome::Shutdown)));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// A restart owes the disk a walk in full, since nothing watched it
|
||||
/// meanwhile, and owes Drive nothing: its event stream resumes from the
|
||||
/// cursor (`root`).
|
||||
|
||||
@@ -1900,6 +1900,13 @@ impl ContentCache {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Drop every pin recorded under `path`. Returns the uids it dropped,
|
||||
/// whose blobs the caller evicts. For a pin whose node is gone, so its
|
||||
/// path no longer resolves to a uid.
|
||||
pub fn remove_pins_at(&self, path: &str) -> Result<Vec<String>> {
|
||||
self.db.pin_remove_by_path(path)
|
||||
}
|
||||
|
||||
/// All pins (files and recursive folders), ordered by uid.
|
||||
pub fn list_pins(&self) -> Vec<Pin> {
|
||||
self.db
|
||||
|
||||
@@ -259,6 +259,9 @@ impl Db {
|
||||
if let Some(rowid) = rowid {
|
||||
tx.execute("DELETE FROM nodes_fts WHERE rowid = ?1", params![rowid])?;
|
||||
}
|
||||
// A pin outlives its node otherwise, listed as kept offline with no
|
||||
// path left to unpin it by.
|
||||
tx.execute("DELETE FROM pins WHERE uid = ?1", params![uid])?;
|
||||
tx.commit()?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -299,6 +302,9 @@ impl Db {
|
||||
if let Some(rowid) = rowid {
|
||||
tx.execute("DELETE FROM nodes_fts WHERE rowid = ?1", params![rowid])?;
|
||||
}
|
||||
// A pin outlives its node otherwise, listed as kept offline with no
|
||||
// path left to unpin it by.
|
||||
tx.execute("DELETE FROM pins WHERE uid = ?1", params![uid])?;
|
||||
tx.execute("DELETE FROM pending_op WHERE id = ?1", params![op_id])?;
|
||||
if let Some(name) = name {
|
||||
wake_ops_waiting_for_tx(&tx, &name)?;
|
||||
|
||||
@@ -38,6 +38,21 @@ impl Db {
|
||||
Ok(n > 0)
|
||||
}
|
||||
|
||||
/// Drop every pin recorded under `path`. Returns the uids it dropped.
|
||||
///
|
||||
/// For a pin whose node is gone: the path no longer resolves to a uid, and
|
||||
/// the recorded path is all that is left to name the pin by.
|
||||
pub fn pin_remove_by_path(&self, path: &str) -> Result<Vec<String>> {
|
||||
let conn = self.conn.lock();
|
||||
let mut stmt = conn.prepare("DELETE FROM pins WHERE path = ?1 RETURNING uid")?;
|
||||
let rows = stmt.query_map(params![path], |r| r.get::<_, String>(0))?;
|
||||
let mut out = Vec::new();
|
||||
for r in rows {
|
||||
out.push(r?);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Every directly-pinned entry, ordered by uid.
|
||||
pub fn pin_list(&self) -> Result<Vec<PinRow>> {
|
||||
let conn = self.read()?;
|
||||
|
||||
@@ -5841,6 +5841,40 @@ fn pin_add_list_remove_roundtrip() {
|
||||
assert_eq!(db.pin_list().unwrap().len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deleting_a_node_drops_its_pin() {
|
||||
// A pin that outlived its node stayed listed as kept offline, and the path
|
||||
// it was listed by no longer resolved, so it could not be unpinned.
|
||||
let db = Db::open_in_memory().unwrap();
|
||||
db.upsert_node(&folder("root", None, "My Files")).unwrap();
|
||||
db.upsert_node(&file("gone", "root", "gone.mkv", 1))
|
||||
.unwrap();
|
||||
db.upsert_node(&file("kept", "root", "kept.mkv", 1))
|
||||
.unwrap();
|
||||
let du = |l: &str| uid(l).to_string();
|
||||
db.pin_add(&du("gone"), "gone.mkv", false).unwrap();
|
||||
db.pin_add(&du("kept"), "kept.mkv", false).unwrap();
|
||||
|
||||
db.delete_node(&uid("gone")).unwrap();
|
||||
|
||||
let pins: Vec<String> = db.pin_list().unwrap().into_iter().map(|p| p.uid).collect();
|
||||
assert_eq!(pins, vec![du("kept")]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_pin_left_behind_is_removed_by_its_path() {
|
||||
let db = Db::open_in_memory().unwrap();
|
||||
db.pin_add("vol~gone", "Videos/gone.mkv", false).unwrap();
|
||||
db.pin_add("vol~kept", "Videos/kept.mkv", false).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
db.pin_remove_by_path("Videos/gone.mkv").unwrap(),
|
||||
vec!["vol~gone".to_string()]
|
||||
);
|
||||
assert!(db.pin_remove_by_path("Videos/gone.mkv").unwrap().is_empty());
|
||||
assert_eq!(db.pin_list().unwrap().len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_pinned_direct_without_node_row() {
|
||||
// A direct pin counts even when the node was never hydrated into `nodes`.
|
||||
|
||||
@@ -22,6 +22,14 @@ use std::fmt;
|
||||
/// Failures in a row after which an effect is reported as blocked.
|
||||
pub const BLOCKED_AFTER: u32 = 5;
|
||||
|
||||
/// The kind of intent for a file or folder removed from disk because Drive
|
||||
/// deleted it. The other kinds are named by [`Pending::intent`](crate::model::Pending::intent).
|
||||
pub const DELETE_LOCAL: &str = "delete-local";
|
||||
|
||||
/// The kind of intent for a file or folder moved to Drive's trash because it
|
||||
/// was deleted on disk.
|
||||
pub const TRASH: &str = "trash";
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum EffectState {
|
||||
/// Sent, or about to be; no result yet.
|
||||
|
||||
@@ -900,7 +900,11 @@ impl Syncer {
|
||||
continue;
|
||||
}
|
||||
outcome.local_changes += 1;
|
||||
if let Err(e) = removed_locally(std::fs::remove_file(&path)) {
|
||||
let intent = self.issue_effect(folder_id, rel, effect::DELETE_LOCAL);
|
||||
let removed = removed_locally(std::fs::remove_file(&path));
|
||||
let error = removed.as_ref().err().map(ToString::to_string);
|
||||
self.settle_effect(intent.as_ref(), error.as_deref());
|
||||
if let Err(e) = removed {
|
||||
warn!(rel, error = %e, "sync: remove local file failed");
|
||||
self.log_activity(
|
||||
ActivityKind::Trash,
|
||||
@@ -925,12 +929,15 @@ impl Syncer {
|
||||
continue;
|
||||
}
|
||||
let remote = r.expect("remote deletion requires a remote file");
|
||||
let intent = self.issue_effect(folder_id, rel, effect::TRASH);
|
||||
let step = Instant::now();
|
||||
let trashed = self
|
||||
.rt
|
||||
.block_on(self.drive.trash_nodes(std::slice::from_ref(&remote.uid)))
|
||||
.and_then(batch::into_unit);
|
||||
self.trace_call(Call::Trash, step.elapsed());
|
||||
let error = trashed.as_ref().err().map(ToString::to_string);
|
||||
self.settle_effect(intent.as_ref(), error.as_deref());
|
||||
if let Err(e) = trashed {
|
||||
warn!(rel, error = %e, "sync: trash remote failed");
|
||||
self.log_activity(
|
||||
@@ -978,8 +985,21 @@ impl Syncer {
|
||||
.store
|
||||
.sync_entries(folder_id)
|
||||
.map_err(|e| format!("reload baseline: {e:?}"))?;
|
||||
let intents: HashMap<String, StoredIntent> = delete_local_dirs
|
||||
.iter()
|
||||
.filter_map(|rel| {
|
||||
let intent = self.issue_effect(folder_id, rel, effect::DELETE_LOCAL)?;
|
||||
Some((rel.clone(), intent))
|
||||
})
|
||||
.collect();
|
||||
for removal in remove_local_dirs(local_root, delete_local_dirs, &mut current) {
|
||||
outcome.local_changes += 1;
|
||||
// Kept is settled too: nothing is left to do about it.
|
||||
let (rel, error) = match &removal {
|
||||
DirRemoval::Removed(rel) | DirRemoval::Kept(rel, _) => (rel, None),
|
||||
DirRemoval::Failed(rel, e) => (rel, Some(e.to_string())),
|
||||
};
|
||||
self.settle_effect(intents.get(rel), error.as_deref());
|
||||
match removal {
|
||||
DirRemoval::Removed(rel) => {
|
||||
let _ = self.store.sync_entry_remove(folder_id, &rel);
|
||||
@@ -1035,12 +1055,15 @@ impl Syncer {
|
||||
);
|
||||
continue;
|
||||
}
|
||||
let intent = self.issue_effect(folder_id, &rel, effect::TRASH);
|
||||
let step = Instant::now();
|
||||
let trashed = self
|
||||
.rt
|
||||
.block_on(self.drive.trash_nodes(&[uid]))
|
||||
.and_then(batch::into_unit);
|
||||
self.trace_call(Call::Trash, step.elapsed());
|
||||
let error = trashed.as_ref().err().map(ToString::to_string);
|
||||
self.settle_effect(intent.as_ref(), error.as_deref());
|
||||
if let Err(e) = trashed {
|
||||
warn!(rel, error = %e, "sync: trash remote folder failed");
|
||||
self.log_activity(ActivityKind::Trash, base_name(&rel), e.to_string(), false);
|
||||
|
||||
@@ -137,15 +137,24 @@ impl Syncer {
|
||||
/// Write the intent of `op` before it is sent (`effect`). In shadow: a
|
||||
/// failure to write it is logged, and the op is sent anyway.
|
||||
fn issue_intent(&self, folder_id: i64, op: &Pending) -> Option<StoredIntent> {
|
||||
let (intent, before) = match self.store.sync_intent_issue(
|
||||
folder_id,
|
||||
op.rel(),
|
||||
op.intent(),
|
||||
now_secs(),
|
||||
) {
|
||||
self.issue_effect(folder_id, op.rel(), op.intent())
|
||||
}
|
||||
|
||||
/// Write the intent of an effect of `kind` on `rel` before it is sent,
|
||||
/// for the ops that are not a [`Pending`], such as a deletion.
|
||||
pub(super) fn issue_effect(
|
||||
&self,
|
||||
folder_id: i64,
|
||||
rel: &str,
|
||||
kind: &'static str,
|
||||
) -> Option<StoredIntent> {
|
||||
let (intent, before) = match self
|
||||
.store
|
||||
.sync_intent_issue(folder_id, rel, kind, now_secs())
|
||||
{
|
||||
Ok(issued) => issued,
|
||||
Err(e) => {
|
||||
debug!(id = folder_id, rel = op.rel(), error = ?e, "sync: cannot record an intent");
|
||||
debug!(id = folder_id, rel, error = ?e, "sync: cannot record an intent");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
@@ -156,8 +165,8 @@ impl Syncer {
|
||||
self.trace_count(Count::UnsureResent, 1);
|
||||
info!(
|
||||
id = folder_id,
|
||||
rel = op.rel(),
|
||||
kind = op.intent(),
|
||||
rel,
|
||||
kind,
|
||||
attempts = intent.attempts,
|
||||
"sync: sending again an effect a stopped daemon may have made"
|
||||
);
|
||||
@@ -170,17 +179,22 @@ impl Syncer {
|
||||
Some(intent)
|
||||
}
|
||||
|
||||
/// Settle or keep `intent` by how its op ended.
|
||||
fn settle_intent(&self, intent: &StoredIntent, op: &Pending, result: &Result<Applied, String>) {
|
||||
let written = match result {
|
||||
Ok(_) => self.store.sync_intent_settle(intent.id),
|
||||
Err(e) => {
|
||||
/// Settle `intent` when its effect succeeded (`error` is `None`), or
|
||||
/// keep it with the failure. No intent, when it could not be written,
|
||||
/// does nothing.
|
||||
pub(super) fn settle_effect(&self, intent: Option<&StoredIntent>, error: Option<&str>) {
|
||||
let Some(intent) = intent else {
|
||||
return;
|
||||
};
|
||||
let written = match error {
|
||||
None => self.store.sync_intent_settle(intent.id),
|
||||
Some(e) => {
|
||||
let state = effect::failed(intent.attempts);
|
||||
if state == EffectState::Blocked && intent.state != EffectState::Blocked.name() {
|
||||
warn!(
|
||||
id = intent.folder_id,
|
||||
rel = op.rel(),
|
||||
kind = op.intent(),
|
||||
rel = %intent.rel_path,
|
||||
kind = %intent.kind,
|
||||
attempts = intent.attempts,
|
||||
error = %e,
|
||||
"sync: an effect keeps failing"
|
||||
@@ -190,7 +204,12 @@ impl Syncer {
|
||||
}
|
||||
};
|
||||
if let Err(e) = written {
|
||||
debug!(id = intent.folder_id, rel = op.rel(), error = ?e, "sync: cannot settle an intent");
|
||||
debug!(
|
||||
id = intent.folder_id,
|
||||
rel = %intent.rel_path,
|
||||
error = ?e,
|
||||
"sync: cannot settle an intent"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,9 +313,7 @@ impl Syncer {
|
||||
let step = Instant::now();
|
||||
let result = self.apply_one(folder_id, local_root, &op).await;
|
||||
self.trace_call(op.call(), step.elapsed());
|
||||
if let Some(intent) = intent {
|
||||
self.settle_intent(&intent, &op, &result);
|
||||
}
|
||||
self.settle_effect(intent.as_ref(), result.as_ref().err().map(String::as_str));
|
||||
self.progress_finished(folder_id);
|
||||
let name = base_name(op.rel());
|
||||
match &result {
|
||||
|
||||
@@ -331,11 +331,14 @@ impl Syncer {
|
||||
let _ = self.store.sync_entry_remove(folder_id, rel);
|
||||
continue;
|
||||
};
|
||||
if let Err(e) = self
|
||||
let intent = self.issue_effect(folder_id, rel, effect::TRASH);
|
||||
let result = self
|
||||
.rt
|
||||
.block_on(self.drive.trash_nodes(&[uid]))
|
||||
.and_then(batch::into_unit)
|
||||
{
|
||||
.and_then(batch::into_unit);
|
||||
let error = result.as_ref().err().map(ToString::to_string);
|
||||
self.settle_effect(intent.as_ref(), error.as_deref());
|
||||
if let Err(e) = result {
|
||||
warn!(rel, error = %e, "sync: trash remote failed");
|
||||
self.log_activity(ActivityKind::Trash, base_name(rel), e.to_string(), false);
|
||||
outcome.failed(&format!("{rel}: {e}"));
|
||||
|
||||
@@ -320,6 +320,14 @@ impl<H: FilesHost> Files<H> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// A queued revision is the whole file, so its length is the
|
||||
// file's, whatever the tree says. The tree can be behind it: an
|
||||
// upload that lands as the next write queues puts its own size
|
||||
// back over the one that write stamped. Taken from the tree, a
|
||||
// longer length left the copied bytes past the blob unauthored,
|
||||
// and the commit refilled them from the older revision. A
|
||||
// shorter one cut the file at that length (docs/BUGS.md B308).
|
||||
let len = pending_base.as_ref().map_or(base.size, |p| p.meta.len);
|
||||
let fh = st.open.open_writer(ino, || {
|
||||
WriteHandle {
|
||||
ino,
|
||||
@@ -329,7 +337,7 @@ impl<H: FilesHost> Files<H> {
|
||||
written: initial_written,
|
||||
// Starts at the current size; reads in [0, base_size)
|
||||
// come from the base until overwritten.
|
||||
len: base.size,
|
||||
len,
|
||||
base_size: base.size,
|
||||
base_mtime: base.mtime,
|
||||
base_revision_id: base.revision_id.clone(),
|
||||
@@ -977,6 +985,49 @@ mod tests {
|
||||
assert_eq!(fx.open_count(ino), 0);
|
||||
}
|
||||
|
||||
/// A queued edit is the whole file, so a write open over it starts at the
|
||||
/// edit's length even when the tree still has an older, longer size.
|
||||
/// Started at the tree's 23 bytes, the hole a write past the edit leaves
|
||||
/// was refilled from the older revision at commit (B308).
|
||||
#[test]
|
||||
fn a_write_open_over_a_queued_edit_takes_the_edits_length() {
|
||||
let fx = Fixture::new();
|
||||
let ino = fx.add("f", false);
|
||||
// The tree has the revision that landed as the edit was queued.
|
||||
if let NodeKind::File { claimed_size, .. } =
|
||||
&mut fx.state().entries.get_mut(&ino).unwrap().node.kind
|
||||
{
|
||||
*claimed_size = Some(23);
|
||||
}
|
||||
let path = fx._dir.0.join("queued");
|
||||
std::fs::write(&path, b"mnopqrst").unwrap();
|
||||
fx.writes.pending.lock().insert(
|
||||
uid("f"),
|
||||
PendingRevision {
|
||||
path,
|
||||
meta: StagedWrite {
|
||||
uid: uid("f").to_string(),
|
||||
len: 8,
|
||||
base_size: 23,
|
||||
base_mtime: 1,
|
||||
authored: vec![(0, 8)],
|
||||
complete: true,
|
||||
based_on: None,
|
||||
},
|
||||
},
|
||||
);
|
||||
let fh = fx.files.open(ino, true).unwrap();
|
||||
fx.files.write(ino, fh, 12, b"hijk").unwrap();
|
||||
let st = fx.state();
|
||||
let handle = st.open.by_fh(fh).unwrap();
|
||||
assert_eq!(handle.len, 16);
|
||||
// Everything is the user's: the edit, the hole and the write.
|
||||
assert_eq!(handle.written.0, vec![(0, 16)]);
|
||||
let mut bytes = vec![0; 16];
|
||||
std::os::unix::fs::FileExt::read_exact_at(&*handle.file, &mut bytes, 0).unwrap();
|
||||
assert_eq!(&bytes, b"mnopqrst\0\0\0\0hijk");
|
||||
}
|
||||
|
||||
/// A write open over a partial queued edit has to fill its gaps from
|
||||
/// Drive first. Offline it fails with the host's own error.
|
||||
#[test]
|
||||
|
||||
@@ -68,6 +68,7 @@ original wording.
|
||||
|
||||
| Entry | Title | What is left |
|
||||
|---|---|---|
|
||||
| [B307](#b307--a-write-in-the-echoes-simulation-can-wait-20-s-for-a-drive-call-that-never-answers) | A write in the echoes simulation can wait 20 s for a Drive call that never answers | Cause not found; seen once in CI |
|
||||
| [B275](#b275--on-a-slow-link-a-files-last-write-can-land-only-in-a-conflict-copy) | On a slow link, a file's last write can land only in a conflict copy | Cause not found; seen once in CI |
|
||||
| [B273](#b273--a-restore-proposes-another-computers-paths-when-the-two-share-a-hostname) | A restore proposes another computer's paths when the two share a hostname | Not fixed |
|
||||
| [B267](#b267--a-key-failure-at-a-start-from-a-warm-cache-shows-as-offline-for-good) | A key failure at a start from a warm cache shows as offline for good | Not fixed |
|
||||
@@ -318,6 +319,7 @@ a live account since.
|
||||
|
||||
| Entry | Title |
|
||||
|---|---|
|
||||
| [B308](#b308--a-write-opened-over-a-queued-edit-took-the-trees-older-size) | A write opened over a queued edit took the tree's older size |
|
||||
| [B295](#b295--a-resize-the-scratch-file-refused-still-succeeded) | A resize the scratch file refused still succeeded |
|
||||
| [B293](#b293--a-large-trash-never-lists-and-empty-trash-never-empties-it) | A large trash never lists, and Empty Trash never empties it |
|
||||
| [B292](#b292--two-programs-changing-settings-at-once-lose-one-of-the-changes) | Two programs changing settings at once lose one of the changes |
|
||||
@@ -409,6 +411,72 @@ a live account since.
|
||||
|
||||
Newest first.
|
||||
|
||||
### B308 — A write opened over a queued edit took the tree's older size
|
||||
|
||||
**Status:** Fixed (unverified)
|
||||
**Found:** 2026-11-28, looping `one_client_with_stale_hashes_and_reordered_echoes` seed 4 under
|
||||
`stress-ng --cpu 4 --cpu-load 70` while chasing B307. Three runs of 89 failed with `liveness: the
|
||||
queues did not drain within 6s`, none with B307's 20 s stall. Run 45 ended with `a.txt` holding
|
||||
`mnopqrstcdefhijk…` where the model has `mnopqrst\0\0\0\0hijk…`, and run 33 with `f.txt` cut at 62
|
||||
bytes of 81.
|
||||
**Where:** `crates/pdfs-vfs/src/files.rs` (`Files::install_writer`) and
|
||||
`crates/pdfs-fuse/src/drain/revision.rs` (`Core::place_landed`)
|
||||
|
||||
**Repro:** Create `a.txt` with 23 bytes and let its upload start. As it lands, open `a.txt` with
|
||||
`O_TRUNC`, write 8 bytes and close. Then open it again and write 4 bytes at offset 12.
|
||||
|
||||
**Cause.** Two steps, each harmless alone:
|
||||
|
||||
- `place_landed` asks `rebaseline_pending` whether a write is queued, and if none is, puts the node
|
||||
it read back into the tree. A write queued between the two stamps its own size first, and the
|
||||
landed node then puts the old size back. The tree said 23 bytes while the queued edit held 8.
|
||||
- `install_writer` copies the queued blob into the new handle's scratch file and marks `[0, 8)` as
|
||||
written, but it started the handle at the tree's size. With 23, the write at 12 left `[8, 12)`
|
||||
unmarked, and the commit filled it from the 23-byte revision instead of zeros. Run 33 was the
|
||||
same with a tree size below the queued edit's, so the handle was cut short.
|
||||
|
||||
**Fix.** A write open over a queued edit starts at the edit's length, since the blob is the whole
|
||||
file. `place_landed` applies queued sizes to the node it read back before putting it in the tree,
|
||||
as listings already do.
|
||||
|
||||
**Verified:** `a_write_open_over_a_queued_edit_takes_the_edits_length` in `pdfs-vfs` fails
|
||||
without the fix (`left: 23, right: 16`) and passes with it. The seed-4 loop under load has not
|
||||
been rerun on the fix yet.
|
||||
|
||||
The third failure, run 59, is likely the same cause by another route. The edit to `a.txt`
|
||||
landed only as a conflict copy ("based on revision rev2, remote now at rev5"). The handle had
|
||||
started at the tree's 23 bytes over the queued 8, so the hole at `[8, 12)` was unauthored and
|
||||
the write was queued with `complete: false`. `is_own_self_supersede` only chains a complete write
|
||||
onto a revision this daemon sealed, so the incomplete one forked. With the length fixed, the hole
|
||||
counts as written and the write is complete.
|
||||
|
||||
---
|
||||
|
||||
### B307 — A write in the echoes simulation can wait 20 s for a Drive call that never answers
|
||||
|
||||
**Status:** Open
|
||||
**Found:** 2026-11-28, CI on #210 ([run](https://github.com/narrrl/proton-drive-linux/actions/runs/46140440107)):
|
||||
`one_client_with_stale_hashes_and_reordered_echoes`, profile `one-client-echoes` seed 4, failed
|
||||
with `liveness: client 0: write c.bin at 25 (4 bytes) took 20.961719651s, over 2s`. #210
|
||||
changes only the GUI, and the same seed passed 28 times locally on `cf2632a`. In the same run,
|
||||
`three_clients_one_writer_each` seed 2 failed with `truncate c.bin to 12 took 2.089572866s`, which is
|
||||
just over the budget and looks like runner load.
|
||||
**Where:** not located; a foreground call bounded by `INTERACTIVE_CALL_TIMEOUT` in
|
||||
`crates/pdfs-fuse/src/link.rs`
|
||||
|
||||
**Repro:** The client creates `c.bin`, writes to it, renames `d` over it, and lets the queue
|
||||
settle. The next write into `c.bin` then succeeds, but only after 21 s.
|
||||
|
||||
**Cause.** Not known. 21 s is the 20 s `INTERACTIVE_CALL_TIMEOUT` plus about a second, so a
|
||||
call the write waited on got no answer from the fake Drive and timed out. The echoes profile
|
||||
delays, duplicates and reorders events, but it never drops a reply or stalls a call. So the
|
||||
call either waited on something held elsewhere, or the fake left it without an answer.
|
||||
|
||||
**Fix.** Not done. Needs a reproduction under load with the state directory and `daemon.log`
|
||||
of a failing run, which the simulation keeps.
|
||||
|
||||
---
|
||||
|
||||
### B306 — A change made as its node's create lands is refused with "Permission denied"
|
||||
|
||||
**Status:** Fixed (unverified)
|
||||
|
||||
@@ -11,6 +11,21 @@ scratch (user data in `staging/` and `recovery/` is never touched by this).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [4.0.0] — 2026-11-28
|
||||
|
||||
4.0.0 splits the daemon into services that each own their state. The sync engine, the mounted
|
||||
files, Drive access, the database and the admission of background work each have a crate of
|
||||
their own (`pdfs-sync`, `pdfs-vfs`, `pdfs-drive`, `pdfs-store`, `pdfs-sched`), and the daemon
|
||||
builds them in `pdfs-daemon` (see [Architecture](ARCHITECTURE.md#40-from-one-daemon-to-composed-services)).
|
||||
A sync pass now keeps track of what each side owes: it lists only what changed on Proton Drive,
|
||||
trusts the watcher for the folder on disk, resumes a walk a restart cut short, and records every
|
||||
effect it sends until the result is in. Small files go up in one request.
|
||||
|
||||
**Upgrading:** the database moves from schema 47 to 52 on first start. 3.10 and older refuse to
|
||||
open it, so going back to 3.10 means removing the cache and letting it build again. Files in
|
||||
`staging/` and `recovery/`, and synced folders on disk, are not touched by this. Nothing else
|
||||
needs doing: configuration, sign-in and synced folders carry over.
|
||||
|
||||
Schema: **52**. New tables save a mirror folder's walk of Proton Drive (48). A finished walk is
|
||||
kept, with a list of the folders that changed on Proton Drive since (49). Each mirror folder
|
||||
counts the deletions it made in the last day (50). Each upload, download or folder a mirror pass
|
||||
@@ -35,6 +50,11 @@ digest of what it sent (52).
|
||||
its own directories, keyring entry, kernel keys and mountpoint, so a test account can run
|
||||
alongside the account you use. `scripts/live-bench.py` uses it to time one edit, from the
|
||||
write to the new revision on Proton Drive.
|
||||
- **`pdfs diagnostics` lists the sync effects that have not settled.** An upload, download,
|
||||
folder or deletion a synced folder's pass sent and has not heard a success for is listed,
|
||||
oldest first, with how many times it was sent, how long ago, and its last error. Deletions on
|
||||
either side are now recorded like the other effects, so one that keeps failing says so in the
|
||||
journal too. The JSON report has them as `effects`.
|
||||
- **`pdfs diagnostics` says how many uploads went up in one request.** It counts the uploads
|
||||
since start that took the one-request path for small files and those that went up in blocks,
|
||||
with their failures and times. If small files stop taking the one-request path, because
|
||||
@@ -91,6 +111,21 @@ digest of what it sent (52).
|
||||
first pass, and whenever the change feed lost track (#53).
|
||||
|
||||
### Fixed
|
||||
- **A write right after another can no longer bring back old bytes or cut the file short.** When
|
||||
an upload landed just as the next edit to the same file was queued, the file could keep the
|
||||
size of the upload that landed. A write opened next then started at that size, not the queued
|
||||
edit's. If the landed size was larger, a gap the write left past the edit was filled from the
|
||||
older revision instead of zeros. If it was smaller, the file was cut at that size. Seen in
|
||||
the echoes simulation about once in 40 runs under CPU load (B308).
|
||||
- **A file kept offline and then deleted can be made online only again.** Deleting or trashing a
|
||||
file left its entry under Settings → Storage → Available offline, and making it online only
|
||||
failed with "could not resolve", because its path no longer led anywhere. Deleting a file now
|
||||
drops the entry with it, and an entry already left behind is removed by the path it is listed
|
||||
under. The app also stops asking for that file's thumbnail every second.
|
||||
- **A share can be stopped from Shared by me when its file was never opened here.** Stopping the
|
||||
share, or changing its people or link, failed with "node is not present in any location" for a
|
||||
file in a folder this computer had not loaded. Drive's own list of what you shared now counts as
|
||||
proof that the file is yours.
|
||||
- **Stopping a sync with "Also delete from Proton Drive" says that it deletes, and says so when
|
||||
the deletion failed.** With the switch on, the dialog now reads "Stop Syncing and Delete
|
||||
Folder?" and its button "Stop Syncing and Delete". If the folder stopped syncing but its folder
|
||||
@@ -2634,6 +2669,7 @@ First stable release: FUSE files-on-demand mount, sync daemon under `proton-driv
|
||||
- The outstanding FUSE defects tracked in `docs/BUGS.md`, plus a truncate defect, validated
|
||||
by a new POSIX compliance suite for the filesystem.
|
||||
|
||||
[4.0.0]: https://github.com/narrrl/proton-drive-linux/releases/tag/v4.0.0
|
||||
[3.10.0]: https://github.com/narrrl/proton-drive-linux/releases/tag/v3.10.0
|
||||
[3.9.0]: https://github.com/narrrl/proton-drive-linux/releases/tag/v3.9.0
|
||||
[3.8.1]: https://github.com/narrrl/proton-drive-linux/releases/tag/v3.8.1
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ That URL follows `main`. To stay on releases, pin the input to a release tag ins
|
||||
the tag to update:
|
||||
|
||||
```nix
|
||||
inputs.proton-drive-linux.url = "github:narrrl/proton-drive-linux/v3.10.0";
|
||||
inputs.proton-drive-linux.url = "github:narrrl/proton-drive-linux/v4.0.0";
|
||||
```
|
||||
|
||||
Each release tag is built with Nix before the release is published.
|
||||
|
||||
+12
-3
@@ -262,7 +262,10 @@ made again reaches Drive within a minute; the second fails without the inode che
|
||||
|
||||
The second reducer, `pdfs_sync::effect`, follows one effect a mirror pass sends: a folder made on
|
||||
Drive, an upload, a new revision, a download, an adopted file or a conflict copy (the `Pending`
|
||||
ops). Before an op is sent, its intent is written to `sync_intent` (schema 51): one row per
|
||||
ops), and the deletions a pass makes: `trash` for a file or folder moved to Drive's trash because
|
||||
it went from disk, `delete-local` for one removed from disk because Drive deleted it. A folder Drive
|
||||
deleted that still holds something Drive never had is kept, and its intent settles: nothing is left
|
||||
to do about it. Before an op is sent, its intent is written to `sync_intent` (schema 51): one row per
|
||||
folder, path and kind, with the number of attempts and the time it was last sent. Its result
|
||||
decides what happens next:
|
||||
|
||||
@@ -302,13 +305,19 @@ that went unanswered.
|
||||
|
||||
Otherwise nothing reads the intents to decide what to send. The apply step's own checks still
|
||||
decide whether an effect that may have landed is sent again (B266 for a create, B39 for a
|
||||
download). Deletions on either side are not recorded yet. Trace counts: `unsure resent`,
|
||||
`retried`, `superseded`.
|
||||
download). Trace counts: `unsure resent`, `retried`, `superseded`.
|
||||
|
||||
`pdfs diagnostics` lists the intents not settled yet, oldest first (at most 20, with the count of
|
||||
all of them), with their kind, state, attempts, age and last error. The list is the
|
||||
`effects` field of the JSON report.
|
||||
|
||||
**Tests:**
|
||||
- the `effect::tests` unit tests;
|
||||
- DB: `an_effect_intent_is_kept_until_it_is_settled_or_its_folder_changes`, and
|
||||
`an_upload_notes_each_digest_it_sent_once`;
|
||||
- sim `a_deletion_is_an_effect_until_it_lands`: a trash held on its way to Drive is listed
|
||||
`issued` in `pdfs diagnostics`, and the list is empty once it lands, and once a file Drive
|
||||
deleted is gone from disk;
|
||||
- sim `an_effect_left_unsure_by_a_stop_is_sent_again_or_settled`: of two uploads a stopped daemon
|
||||
left unsure, the one still needed is sent again and the other is settled;
|
||||
- sim `a_mirror_create_whose_reply_was_lost_is_adopted_after_a_restart_and_its_edit_lands`:
|
||||
|
||||
@@ -331,7 +331,12 @@ What the parts mean:
|
||||
from; the apply step checks whether each already landed before it sends it. **`retried`**
|
||||
counts effects sent again after a failure, and **`superseded`** counts unsettled effects of
|
||||
earlier passes that were no longer needed. A `sync: an effect keeps failing` line names an
|
||||
upload, download or folder that failed five times in a row.
|
||||
upload, download, folder or deletion that failed five times in a row.
|
||||
The `sync effects not settled` lines in `pdfs diagnostics` list the oldest of these effects
|
||||
now, one per line, for example
|
||||
`folder 2 trash Old/report.pdf: retry, sent 3 times, 12m4s ago (timed out)`. `issued` means
|
||||
sent and waiting for an answer, `unsure` means a stopped daemon sent it and the next pass has
|
||||
not looked yet, and `retry` or `blocked` means it failed.
|
||||
|
||||
Please include these lines when you report a slow folder.
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
# Build + install: cd packaging && makepkg -fi
|
||||
|
||||
pkgname=proton-drive-linux
|
||||
pkgver=3.10.0
|
||||
pkgver=4.0.0
|
||||
pkgrel=1
|
||||
pkgdesc="Unofficial Proton Drive client for Linux: files-on-demand FUSE mount, CLI, GTK4 app + tray"
|
||||
arch=('x86_64')
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# Match Arch PKGBUILD `!lto` — LTO has broken some GTK/Rust links in practice.
|
||||
%global _lto_cflags %{nil}
|
||||
|
||||
%{!?version: %global version 3.10.0}
|
||||
%{!?version: %global version 4.0.0}
|
||||
%global forge https://github.com/narrrl/proton-drive-linux
|
||||
# Files come from the checkout, or from the unpacked tag archive.
|
||||
%global src %{?git_dir}%{!?git_dir:.}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: proton-drive-linux 3.10.0\n"
|
||||
"Project-Id-Version: proton-drive-linux 4.0.0\n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/narrrl/proton-drive-linux/issues\n"
|
||||
"POT-Creation-Date: 2026-11-28 12:27+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
|
||||
Reference in new issue
Block a user