One read of a device's link: state::credentials, with the client's seal

Five places read the server address and token straight from sync_state:
sharing, autosync, sync_unlink, update's download token, and the ffi. Reading it
raw is how Android came to send its sealed token to the share routes (#5381).
state::credentials(conn, seal) now holds that read. With a seal it opens the token
(open_token), and without one (the desktop keeps it plain) it returns it as stored.
Every site calls it.

DRY pass #2, batch 1, F1 (#5372).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 14:14:18 -04:00
co-authored by Claude Opus 5.5
parent 17ae8c0863
commit 70274347af
6 changed files with 37 additions and 32 deletions
+1 -2
View File
@@ -176,8 +176,7 @@ fn backoff(failures: u32) -> Duration {
/// The server URL and token, or None when this device isn't linked.
fn credentials(db: &Db) -> Result<Option<(String, String)>, String> {
let conn = db.conn()?;
let current = state::read(&conn).map_err(|e| e.to_string())?;
Ok(current.server_url.zip(current.device_token))
state::credentials(&conn, None).map_err(|e| e.to_string())
}
/// What is waiting to be sent, as [`push::pending_fingerprint`] sees it. A store