diff --git a/crates/pdfs-cli/src/main.rs b/crates/pdfs-cli/src/main.rs index b0e4bd3..5a4308c 100644 --- a/crates/pdfs-cli/src/main.rs +++ b/crates/pdfs-cli/src/main.rs @@ -2688,18 +2688,25 @@ fn cmd_daemon(mountpoint: Option) -> Result<()> { let error = format!("{e:#}"); let now = unix_now(); let attempts = failure.as_ref().map_or(1, |f| f.attempts.saturating_add(1)); - let delay = mount_retry_delay(attempts); - tracing::error!( - error, - attempts, - retry_secs = delay.as_secs(), - "mount failed; retrying" - ); + let delay = mount_retry_schedule(&e, attempts); + match delay { + Some(delay) => tracing::error!( + error, + attempts, + retry_secs = delay.as_secs(), + "mount failed; retrying" + ), + None => tracing::error!( + error, + attempts, + "account keys could not open My Files; waiting for service restart" + ), + } let record = pdfs_core::mountfail::MountFailure { error: error.clone(), since: failure.as_ref().map_or(now, |f| f.since), attempts, - next_attempt: now + delay.as_secs() as i64, + next_attempt: delay.map(|delay| now + delay.as_secs() as i64), not_empty: not_empty_cause(&e), }; if let Err(e) = pdfs_core::mountfail::record(&state_dir, &record) { @@ -2707,7 +2714,12 @@ fn cmd_daemon(mountpoint: Option) -> Result<()> { } pdfs_fuse::notify_status(&format!("Mount failing: {error}")); failure = Some(record); - pdfs_fuse::idle_sleep(delay); + // Retry and a successful login restart the service. Keep the + // watchdog alive while parked without contacting Proton. + match delay { + Some(delay) => pdfs_fuse::idle_sleep(delay), + None => return pdfs_fuse::wait_for_restart().context("wait for key recovery"), + } } } } @@ -2730,6 +2742,20 @@ fn not_empty_cause(error: &anyhow::Error) -> Option Option { + let root = error.chain().find_map(|cause| { + cause + .downcast_ref::()? + .get_ref()? + .downcast_ref::() + }); + if root.is_some_and(|root| root.needs_account_keys()) { + None + } else { + Some(mount_retry_delay(attempts)) + } +} + /// How long to wait before mount attempt `attempts + 1`, after `attempts` /// failures in a row. /// @@ -4631,7 +4657,11 @@ fn cmd_diagnose() -> Result<()> { "failing for {}, {} attempt(s): {}", human_secs(unix_now().saturating_sub(failure.since).max(0) as u64), failure.attempts, - failure.error + if failure.next_attempt.is_none() { + format!("{} — after recovering your account keys, restart proton-drive.service", failure.error) + } else { + failure.error + } ), ), None => println!( @@ -4893,6 +4923,26 @@ mod login_wait_tests { assert_eq!(mount_retry_delay(u32::MAX).as_secs(), 120); } + #[test] + fn cold_root_key_failures_wait_for_a_restart() { + use pdfs_core::proton_sdk::{ProtonError, crypto::CryptoError}; + for (cause, parked) in [ + (ProtonError::KeysLocked, true), + (CryptoError::Decrypt("missing key".into()).into(), true), + (CryptoError::Decrypt("malformed data".into()).into(), false), + (ProtonError::invalid_operation("missing key"), false), + ] { + let io = std::io::Error::other(pdfs_core::mountfail::RootLookup(cause)); + let error = anyhow::Error::new(io).context("mount failed"); + assert_eq!(mount_retry_schedule(&error, 1).is_none(), parked); + } + let io = std::io::Error::from(std::io::ErrorKind::NetworkUnreachable); + assert_eq!( + mount_retry_schedule(&io.into(), 1), + Some(mount_retry_delay(1)) + ); + } + /// A refusal over a folder with files in it reaches the failure record /// through the `io::Error` and the context around it (`docs/BUGS.md` B277). #[test] diff --git a/crates/pdfs-core/src/mountfail.rs b/crates/pdfs-core/src/mountfail.rs index 277d98d..5946acc 100644 --- a/crates/pdfs-core/src/mountfail.rs +++ b/crates/pdfs-core/src/mountfail.rs @@ -13,6 +13,22 @@ use serde::{Deserialize, Serialize}; /// The file's name inside the state directory. const FILE_NAME: &str = "mount-failure.json"; +/// Failure to fetch My Files on a cold start with no cached root. +#[derive(Debug, thiserror::Error)] +#[error("fetch My Files root: {0}")] +pub struct RootLookup(pub proton_sdk::ProtonError); + +impl RootLookup { + pub fn needs_account_keys(&self) -> bool { + use proton_sdk::{ProtonError, crypto::CryptoError}; + + // SDK 0.12 exposes the underlying PGP missing-key reason as the + // payload of Decrypt. Never park for an unrelated decryption error. + matches!(self.0, ProtonError::KeysLocked) + || matches!(&self.0, ProtonError::Crypto(CryptoError::Decrypt(reason)) if reason == "missing key") + } +} + /// The last failed mount attempt. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] pub struct MountFailure { @@ -22,8 +38,8 @@ pub struct MountFailure { pub since: i64, /// Failed attempts in a row. pub attempts: u32, - /// Unix seconds of the next attempt. - pub next_attempt: i64, + /// Unix seconds of the next attempt, or None while waiting for key recovery. + pub next_attempt: Option, /// Set when the mount was refused because the folder already has files in /// it, so the app can explain that in the user's language. Absent in a /// file an older daemon wrote. @@ -67,7 +83,7 @@ mod tests { error: "fetch My Files root: missing key".into(), since: 1_700_000_000, attempts: 3, - next_attempt: 1_700_000_040, + next_attempt: Some(1_700_000_040), not_empty: None, }; record(&dir, &failure).unwrap(); @@ -81,6 +97,7 @@ mod tests { fn a_failure_an_older_daemon_wrote_still_reads() { let old = r#"{"error":"missing key","since":1,"attempts":2,"next_attempt":3}"#; let failure: MountFailure = serde_json::from_str(old).unwrap(); + assert_eq!(failure.next_attempt, Some(3)); assert_eq!(failure.not_empty, None); assert_eq!(failure.attempts, 2); } diff --git a/crates/pdfs-fuse/src/lib.rs b/crates/pdfs-fuse/src/lib.rs index fc772e5..23fe0e3 100644 --- a/crates/pdfs-fuse/src/lib.rs +++ b/crates/pdfs-fuse/src/lib.rs @@ -129,7 +129,9 @@ use mount::{ }; use reads::{BlockFlight, BlockRing, PREFETCH_BUDGET, Prefetch, ReaderSlot, STREAM_BYPASS_MIN}; use state::{Entry, Intervals, PendingRevision, State, StateGuard, WriteHandle}; -pub use systemd::{idle_sleep, status as notify_status, stretch_watchdog_for_startup}; +pub use systemd::{ + idle_sleep, status as notify_status, stretch_watchdog_for_startup, wait_for_restart, +}; use tracing::{debug, error, info, warn}; use transfers::{CountingWriter, JobGuard, OwnedCountingReader, TransferRegistry}; use r#virtual::{ diff --git a/crates/pdfs-fuse/src/mount.rs b/crates/pdfs-fuse/src/mount.rs index d2fadd9..6706d46 100644 --- a/crates/pdfs-fuse/src/mount.rs +++ b/crates/pdfs-fuse/src/mount.rs @@ -291,7 +291,7 @@ fn fetch_or_recall_root( None if start == Start::SessionExpired => Err(std::io::Error::other(format!( "Proton refused the session ({err}); run `pdfs login`" ))), - None => Err(std::io::Error::other(format!("fetch My Files root: {err}"))), + None => Err(std::io::Error::other(pdfs_core::mountfail::RootLookup(err))), } } diff --git a/crates/pdfs-fuse/src/systemd.rs b/crates/pdfs-fuse/src/systemd.rs index 809f305..2c7ea03 100644 --- a/crates/pdfs-fuse/src/systemd.rs +++ b/crates/pdfs-fuse/src/systemd.rs @@ -102,6 +102,27 @@ pub fn idle_sleep(duration: Duration) { } } +/// Keep a cold daemon available for a service restart after key recovery. +pub fn wait_for_restart() -> std::io::Result<()> { + use tokio::signal::unix::{SignalKind, signal}; + + tokio::runtime::Builder::new_current_thread() + .enable_all() + .build()? + .block_on(async { + let mut terminate = signal(SignalKind::terminate())?; + let mut interrupt = signal(SignalKind::interrupt())?; + let mut tick = tokio::time::interval(Duration::from_secs(10)); + loop { + tokio::select! { + _ = terminate.recv() => return Ok(()), + _ = interrupt.recv() => return Ok(()), + _ = tick.tick() => watchdog_ping(), + } + } + }) +} + /// How long a mount may take to start before the watchdog counts it as hung. /// /// Startup has no control socket to probe yet, and on a large account it is diff --git a/crates/pdfs-gui/src/app/main.rs b/crates/pdfs-gui/src/app/main.rs index 3e9777c..207ac97 100644 --- a/crates/pdfs-gui/src/app/main.rs +++ b/crates/pdfs-gui/src/app/main.rs @@ -1993,6 +1993,15 @@ pub(crate) fn service_unreachable( offer_not_empty(&ui, found); } } + Some(failure) if failure.next_attempt.is_none() => status( + &ui, + "dialog-warning-symbolic", + &gettext("Can't open your Drive"), + &gettext( + "Your account keys could not open My Files. After recovering your keys, choose Retry.", + ), + true, + ), Some(failure) => status( &ui, "dialog-warning-symbolic", diff --git a/crates/pdfs-gui/src/app/pages/status.rs b/crates/pdfs-gui/src/app/pages/status.rs index 4452a01..b3e54a2 100644 --- a/crates/pdfs-gui/src/app/pages/status.rs +++ b/crates/pdfs-gui/src/app/pages/status.rs @@ -1430,6 +1430,7 @@ pub(crate) fn paint_disconnected(ui: &Rc) { match failure { Some(failure) => SyncState::CannotOpen { not_empty: failure.not_empty.is_some(), + waiting_for_keys: failure.next_attempt.is_none(), }, None => SyncState::Disconnected, }, @@ -1482,6 +1483,7 @@ pub(crate) enum SyncState { /// it refuses a folder that already has files in it. CannotOpen { not_empty: bool, + waiting_for_keys: bool, }, /// The daemon is running but didn't answer in time. NotResponding, @@ -1586,11 +1588,18 @@ fn paint_sync_status(ui: &Rc, state: SyncState) { gettext("Not connected"), Some(gettext("Proton Drive isn't running")), ), - SyncState::CannotOpen { not_empty } => ( + SyncState::CannotOpen { + not_empty, + waiting_for_keys, + } => ( "dialog-warning-symbolic", Some("warning"), gettext("Can't open your Drive"), - Some(if not_empty { + Some(if waiting_for_keys { + gettext( + "Your account keys could not open My Files. After recovering your keys, choose Retry.", + ) + } else if not_empty { gettext("Your Proton Drive folder isn't empty") } else { gettext("Proton Drive keeps trying to start") diff --git a/crates/pdfs-gui/src/main.rs b/crates/pdfs-gui/src/main.rs index 621fefb..d62dd1e 100644 --- a/crates/pdfs-gui/src/main.rs +++ b/crates/pdfs-gui/src/main.rs @@ -197,18 +197,21 @@ fn poll_state(socket: &Path, default_mountpoint: &Path) -> DriveState { // A daemon whose mount fails on every try never opens the // socket; the app says why (B263). Ok(s) - if socket - .parent() - .and_then(pdfs_core::mountfail::read) - .is_some() => + if let Some(failure) = socket.parent().and_then(pdfs_core::mountfail::read) => { ( - // Translators: {username} is the Proton account name. The - // service keeps failing to start; the app shows the error. - gettext_f( - "Signed in as {username} — can't open your Drive", - &[("username", &s.username)], - ), + if failure.next_attempt.is_none() { + gettext( + "Your account keys could not open My Files. After recovering your keys, choose Retry.", + ) + } else { + // Translators: {username} is the Proton account name. The + // service keeps failing to start; the app shows the error. + gettext_f( + "Signed in as {username} — can't open your Drive", + &[("username", &s.username)], + ) + }, Phase::Attention, ) } diff --git a/docs/BUGS.md b/docs/BUGS.md index bbddb99..25a069a 100644 --- a/docs/BUGS.md +++ b/docs/BUGS.md @@ -1335,7 +1335,7 @@ and stop. ### B263 — A mount that can never succeed retries every 5 s and tells only the journal -**Status:** Partly fixed. Errors that no retry fixes are not told apart from network errors yet. +**Status:** Partly fixed. A cold root lookup that needs account keys waits for recovery. Other persistent startup errors still back off and retry. **Found:** 2026-10-31, issue #40: the app showed "Connecting… waiting for the Proton Drive service" for days, `pdfs diagnose` only reported the control socket missing, and the reporter uninstalled. @@ -1363,7 +1363,7 @@ the error is written nowhere a front end can read it. - The app shows "Can't open your Drive" with the error and a Retry button instead of "Connecting…". The tray says "Signed in as … — can't open your Drive". `pdfs diagnose` reports `[FAIL] mount: failing for …`. `systemctl --user status` shows the error as the unit's status. -- Not done: key, `KeysLocked` and 4xx errors still retry like network errors, only less often. +- With no cached root, a locked keychain or a missing decryption key parks the daemon until Retry or a fresh login restarts the service (#40). Other crypto and HTTP errors still use the bounded retry schedule. **Test:** `a_failing_mount_backs_off_to_a_ceiling` in `pdfs-cli`; `a_recorded_failure_reads_back_until_cleared` in `pdfs-core`. On 2026-10-31 a second diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a1c894d..43d704a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,8 @@ scratch (user data in `staging/` and `recovery/` is never touched by this). ## [Unreleased] +- A cold mount whose account keys cannot open My Files waits for Retry or a fresh sign-in (#40). + ## [3.10.0] — 2026-11-22 Schema: **47**. The trash table gets an index on the original folder, and its stored rows are diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md index 4de01f3..8c6a0cc 100644 --- a/docs/TROUBLESHOOTING.md +++ b/docs/TROUBLESHOOTING.md @@ -162,7 +162,13 @@ session before it shows your files. ### `fetch My Files root: … failed to decrypt: missing key` in the log -Your account keys cannot open your Drive, which happens after a password reset: Proton locks the +If Drive on the web opens your files, run `pdfs diagnose` and check the **Keys** section. +A missing address key can prevent My Files from opening even when sign-in succeeded. On a +cold start with no cached root the daemon waits for key recovery. After recovering your keys, +choose **Retry** in the app or run `systemctl --user restart proton-drive.service`. If it still +fails, include the client version and the redacted Keys findings in your report. + +If the web app also shows locked files after a password reset, Proton locks the files that were encrypted with the old keys. Since 3.4.1 the client then starts a new, empty My files. Your old files are still there, locked: open [drive.proton.me](https://drive.proton.me) and restore them with your previous password. If your files are not locked and the error stays, run diff --git a/images/issue-40.png b/images/issue-40.png new file mode 100644 index 0000000..15c84ce Binary files /dev/null and b/images/issue-40.png differ diff --git a/po/de.po b/po/de.po index f8826f7..f41c504 100644 --- a/po/de.po +++ b/po/de.po @@ -57,6 +57,10 @@ msgstr "%-d. %b %Y" msgid "%A, %B %-d, %Y, %H:%M" msgstr "%A, %-d. %B %Y, %H:%M" +#: crates/pdfs-gui/src/app/main.rs crates/pdfs-gui/src/app/pages/status.rs crates/pdfs-gui/src/main.rs +msgid "Your account keys could not open My Files. After recovering your keys, choose Retry." +msgstr "Deine Kontoschlüssel konnten „Meine Dateien“ nicht öffnen. Stelle die Schlüssel wieder her und wähle „Erneut versuchen“." + #: crates/pdfs-gui/src/app/main.rs:961 #: crates/pdfs-gui/src/app/pages/activity_text.rs:543 #: crates/pdfs-gui/src/app/pages/browser.rs:473 diff --git a/po/en_GB.po b/po/en_GB.po index 02be235..0b6e01b 100644 --- a/po/en_GB.po +++ b/po/en_GB.po @@ -57,6 +57,10 @@ msgstr "%-d %b %Y" msgid "%A, %B %-d, %Y, %H:%M" msgstr "%A %-d %B %Y, %H:%M" +#: crates/pdfs-gui/src/app/main.rs crates/pdfs-gui/src/app/pages/status.rs crates/pdfs-gui/src/main.rs +msgid "Your account keys could not open My Files. After recovering your keys, choose Retry." +msgstr "Your account keys could not open My Files. After recovering your keys, choose Retry." + #: crates/pdfs-gui/src/app/main.rs:961 #: crates/pdfs-gui/src/app/pages/activity_text.rs:543 #: crates/pdfs-gui/src/app/pages/browser.rs:473 diff --git a/po/es.po b/po/es.po index 1fbdb05..5c35bb0 100644 --- a/po/es.po +++ b/po/es.po @@ -57,6 +57,10 @@ msgstr "%-d %b %Y" msgid "%A, %B %-d, %Y, %H:%M" msgstr "%A, %-d de %B de %Y, %H:%M" +#: crates/pdfs-gui/src/app/main.rs crates/pdfs-gui/src/app/pages/status.rs crates/pdfs-gui/src/main.rs +msgid "Your account keys could not open My Files. After recovering your keys, choose Retry." +msgstr "Las claves de tu cuenta no pudieron abrir Mis archivos. Tras recuperarlas, selecciona Reintentar." + #: crates/pdfs-gui/src/app/main.rs:961 #: crates/pdfs-gui/src/app/pages/activity_text.rs:543 #: crates/pdfs-gui/src/app/pages/browser.rs:473 diff --git a/po/fr.po b/po/fr.po index 7112644..694948e 100644 --- a/po/fr.po +++ b/po/fr.po @@ -57,6 +57,10 @@ msgstr "%-d %b %Y" msgid "%A, %B %-d, %Y, %H:%M" msgstr "%A %-d %B %Y à %H:%M" +#: crates/pdfs-gui/src/app/main.rs crates/pdfs-gui/src/app/pages/status.rs crates/pdfs-gui/src/main.rs +msgid "Your account keys could not open My Files. After recovering your keys, choose Retry." +msgstr "Les clés de votre compte n’ont pas pu ouvrir Mes fichiers. Après les avoir récupérées, choisissez Réessayer." + #: crates/pdfs-gui/src/app/main.rs:961 #: crates/pdfs-gui/src/app/pages/activity_text.rs:543 #: crates/pdfs-gui/src/app/pages/browser.rs:473 diff --git a/po/it.po b/po/it.po index bf4d890..4605cad 100644 --- a/po/it.po +++ b/po/it.po @@ -57,6 +57,10 @@ msgstr "%-d %b %Y" msgid "%A, %B %-d, %Y, %H:%M" msgstr "%A %-d %B %Y, %H:%M" +#: crates/pdfs-gui/src/app/main.rs crates/pdfs-gui/src/app/pages/status.rs crates/pdfs-gui/src/main.rs +msgid "Your account keys could not open My Files. After recovering your keys, choose Retry." +msgstr "Le chiavi del tuo account non hanno potuto aprire I miei file. Dopo averle recuperate, scegli Riprova." + #: crates/pdfs-gui/src/app/main.rs:961 #: crates/pdfs-gui/src/app/pages/activity_text.rs:543 #: crates/pdfs-gui/src/app/pages/browser.rs:473 diff --git a/po/nl.po b/po/nl.po index df6c5e0..a312120 100644 --- a/po/nl.po +++ b/po/nl.po @@ -57,6 +57,10 @@ msgstr "%-d %b %Y" msgid "%A, %B %-d, %Y, %H:%M" msgstr "%A %-d %B %Y, %H:%M" +#: crates/pdfs-gui/src/app/main.rs crates/pdfs-gui/src/app/pages/status.rs crates/pdfs-gui/src/main.rs +msgid "Your account keys could not open My Files. After recovering your keys, choose Retry." +msgstr "Je accountsleutels konden Mijn bestanden niet openen. Herstel je sleutels en kies Opnieuw proberen." + #: crates/pdfs-gui/src/app/main.rs:961 #: crates/pdfs-gui/src/app/pages/activity_text.rs:543 #: crates/pdfs-gui/src/app/pages/browser.rs:473 diff --git a/po/pdfs.pot b/po/pdfs.pot index e988d16..a59bcae 100644 --- a/po/pdfs.pot +++ b/po/pdfs.pot @@ -60,6 +60,10 @@ msgstr "" msgid "%A, %B %-d, %Y, %H:%M" msgstr "" +#: crates/pdfs-gui/src/app/main.rs crates/pdfs-gui/src/app/pages/status.rs crates/pdfs-gui/src/main.rs +msgid "Your account keys could not open My Files. After recovering your keys, choose Retry." +msgstr "" + #: crates/pdfs-gui/src/app/main.rs:961 #: crates/pdfs-gui/src/app/pages/activity_text.rs:543 #: crates/pdfs-gui/src/app/pages/browser.rs:473 diff --git a/po/pl.po b/po/pl.po index c05c2a0..d553d5f 100644 --- a/po/pl.po +++ b/po/pl.po @@ -59,6 +59,10 @@ msgstr "%-d %b %Y" msgid "%A, %B %-d, %Y, %H:%M" msgstr "%A, %-d %B %Y, %H:%M" +#: crates/pdfs-gui/src/app/main.rs crates/pdfs-gui/src/app/pages/status.rs crates/pdfs-gui/src/main.rs +msgid "Your account keys could not open My Files. After recovering your keys, choose Retry." +msgstr "Klucze konta nie pozwoliły otworzyć sekcji Moje pliki. Po odzyskaniu kluczy wybierz Ponów próbę." + #: crates/pdfs-gui/src/app/main.rs:961 #: crates/pdfs-gui/src/app/pages/activity_text.rs:543 #: crates/pdfs-gui/src/app/pages/browser.rs:473 diff --git a/po/pt_BR.po b/po/pt_BR.po index ef0b0f8..f01a777 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -57,6 +57,10 @@ msgstr "%-d de %b de %Y" msgid "%A, %B %-d, %Y, %H:%M" msgstr "%A, %-d de %B de %Y, %H:%M" +#: crates/pdfs-gui/src/app/main.rs crates/pdfs-gui/src/app/pages/status.rs crates/pdfs-gui/src/main.rs +msgid "Your account keys could not open My Files. After recovering your keys, choose Retry." +msgstr "As chaves da sua conta não conseguiram abrir Meus arquivos. Após recuperá-las, selecione Tentar novamente." + #: crates/pdfs-gui/src/app/main.rs:961 #: crates/pdfs-gui/src/app/pages/activity_text.rs:543 #: crates/pdfs-gui/src/app/pages/browser.rs:473