Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.
fix(core): the identity file is private from its first byte, and small queue fixes
Beeaeffc8d5f1a3
diff --git a/core/nectarlink-core/src/identity.rs b/core/nectarlink-core/src/identity.rsindex 4957a01..b4ead3a 100644--- a/core/nectarlink-core/src/identity.rs+++ b/core/nectarlink-core/src/identity.rs@@ -102,12 +102,17 @@ fn decode(bytes: &[u8], protector: &dyn KeyProtector) -> Result<SecretKey> {fn write_atomically(path: &Path, data: &[u8]) -> io::Result<()> {let tmp = path.with_extension("tmp");{- let mut file = fs::File::create(&tmp)?;+ // A fresh file, private from the start: a leftover (or a link) at+ // the temporary path is removed rather than written through.+ let _ = fs::remove_file(&tmp);+ let mut options = fs::OpenOptions::new();+ options.write(true).create_new(true);#[cfg(unix)]{- use std::os::unix::fs::PermissionsExt;- file.set_permissions(fs::Permissions::from_mode(0o600))?;+ use std::os::unix::fs::OpenOptionsExt;+ options.mode(0o600);}+ let mut file = options.open(&tmp)?;file.write_all(data)?;file.sync_all()?;}diff --git a/core/nectarlink-core/src/store.rs b/core/nectarlink-core/src/store.rsindex 9d10e95..2a90af7 100644--- a/core/nectarlink-core/src/store.rs+++ b/core/nectarlink-core/src/store.rs@@ -272,7 +272,7 @@ impl QueuePayload {files.first().and_then(|f| f.folder.as_deref())- .and_then(|f| f.split('/').next())+ .and_then(|f| f.split('/').find(|s| !s.is_empty())).unwrap_or("Folder").to_owned()} else {@@ -2133,8 +2133,17 @@ fn lookup_peer_name_conn(c: &Connection, peer: &DeviceId) -> String {pub type DecodedQueueRow = (QueueItem, QueuePayload, Option<Vec<u8>>, i64);fn decode_queue_row(c: &Connection, raw: RawQueueRow, include_blob: bool) -> Option<DecodedQueueRow> {- let peer = raw.peer_str.parse::<DeviceId>().ok()?;- let payload = serde_json::from_str::<QueuePayload>(&raw.payload_json).ok()?;+ // A row this version can't read is left out of the queue; say so, so it+ // doesn't just vanish.+ let decoded = raw+ .peer_str+ .parse::<DeviceId>()+ .ok()+ .zip(serde_json::from_str::<QueuePayload>(&raw.payload_json).ok());+ let Some((peer, payload)) = decoded else {+ tracing::warn!(id = %raw.id, "can't read a queued send; leaving it out of the queue");+ return None;+ };let kind = QueueKind::from_str_opt(&raw.kind_str).unwrap_or_else(|| payload.kind());let status = match raw.status_str.as_str() {"sending" => QueueStatus::Sending,