The daemon's run loop moves out of pdfs-cli into a new crate. run waits
for a stored session, then opens the database and the content cache,
resumes the session on a runtime of its own, and mounts. It remounts
after an external unmount, and retries a failed mount with a backoff,
recording each failure. pdfs daemon and pdfs mount call into it.
Moved unchanged, with their nine tests: login_poll_delay,
wait_for_session, not_empty_cause, mount_retry_schedule,
mount_retry_delay, mount_once and release_runtime. cmd_daemon becomes
pdfs_daemon::run.
The services the mount starts are still built in pdfs-fuse. Moving their
construction here is the next part of step 3.
- resolve.rs: finding nodes by path or uid, in the tree, the database and
on Drive (15 methods).
- remote.rs: renames, moves and content changes sent straight to Drive
(6 methods).
- requests.rs: the control socket's requests by path: list, open,
rename, move, copy, delete, restore a replaced file (25 methods).
- activity.rs: the activity log (2 methods).
No behaviour changes.
- enqueue.rs: turning what the mount was asked into queued ops, and
taking them back (17 methods).
- listing.rs: when a folder is listed again and what a listing from
Drive is merged with (10 methods).
- pins.rs: pin, unpin and the pin listings (8 methods).
- recovery.rs: rebuilding the tree and the queue at startup, and
recovering fsynced writes (5 methods).
- search.rs: the search requests (4 methods).
- echoes.rs: our own changes echoed back by the event feed, with
SelfChange and its helpers.
The source-order tests read Core's code through CORE_SOURCE, lib.rs and
the modules its methods were split into. No behaviour changes.
- maintenance.rs takes the Maintenance struct and the two Core methods
that start a VACUUM or a deep integrity check.
- The quota answer and its refresh flag become sharing::QuotaCache, held
as Core::quota_cache, next to the statfs code that uses them.
- The sweep mode and the copies already checked become sweep::SweepState,
held as Core::sweep.
- Two source-order tests read apply_size_upgrade, run_size_upgrade and
ensure_shared_children from their new files.
No behaviour changes.
Eight Core methods that build and refresh the mounted shared tree's
listing move out of lib.rs into shared.rs. The three Core fields they use
(the publication lock, the generation and the refresh deadlines) become
shared::SharedState, held as Core::shared. The pure naming rules stay in
virtual.rs. No behaviour changes.
Nine Core methods (list, refresh, restore, delete forever, empty) and
their three helpers move out of lib.rs into trash.rs. The two Core fields
the refresh uses become trash::TrashState, held as Core::trash. No
behaviour changes.
The size upgrades fill in the file sizes a cheap listing left out. Their
code (nine Core methods, SizeUpgrade, SizeWaitQueue and their tests) moves
out of lib.rs into sizes.rs, and their two Core fields become
sizes::SizeState, held as Core::sizes. No behaviour changes.
Six of Core's fields belong to the read path alone: the open revision
readers, the decrypted block ring, the block fetches in flight, the
whole-file repair locks, and the prefetch detector with its permits.
They move into one ReadState struct in reads.rs, which Core holds as
reads. Every access was already in reads.rs.
The size upgrades stay in Core: they serve getattr, not reads.
The third group of step 3 in docs/ARCHITECTURE.md. No behaviour changes.
Eight of Core's fields belong to the write-back drain: its wake-up, the
creates and uploads on the wire (creating, upload_cancel, upload_times,
landing_uploads), and what a landed one leaves behind until the tree
catches up (landed, unadopted, sealed_unread). They move into one
DrainState struct in drain.rs, which Core holds as drain.
pending and hidden stay in Core: the reads and the FUSE handlers use
them as much as the drain does.
The second group of step 3 in docs/ARCHITECTURE.md. No behaviour changes.
Twelve of Core's fields belong to the Photos and thumbnail jobs alone:
the timeline, album and similar-photo refresh flags, the thumbnail
generation set and its permits, the listing and recursive-build
cancellation, and the negative thumbnail caches. They move into one
PhotoJobs struct in photos.rs, which Core holds as photo_jobs.
The first group of step 3 in docs/ARCHITECTURE.md. No behaviour changes.
The mount kept its long-lived threads in a bare list of join handles,
and the calls that wake the ones blocked outside the shutdown signal sat
in halt_workers, far from where each thread was started. Nothing could
say which threads were still alive.
pdfs_core::lifecycle::Services starts each thread with its name and its
wake call. A stop signals, wakes and joins them in reverse start order
under the existing 10-second deadline. ServiceBoard is the live view:
`pdfs diagnostics` lists the services and names any that ended, and the
supervisor warns once about a service that ended while the mount runs.
The shutdown inhibitor is now joined too. The sync engine thread is
started by the mount; pdfs_sync::mirror::spawn becomes run.
The scan, the hash and open before an upload, the placement of a
download, the removals and the conflict copy move from mirror.rs into
mirror/local.rs unchanged. Placement is split out of download_file as
staging_path and place_download. This is the first step towards the
LocalFs port; no behaviour changes.
Also puts the open_to_upload doc comment back on open_to_upload; it sat
above revisions_to_record.
The mirror engine held the whole database (`Arc<Db>`) but uses only the
18 calls on its own tables: synced folders, baselines, the saved walk of
Drive and its dirty marks. `SyncStore` is exactly those calls, the
database implements it by forwarding, and `SyncParts` now holds an
`Arc<dyn SyncStore>`. No behaviour changes.
sync.rs and sync/{engine,host,local_scan}.rs become pdfs_sync::mirror.
The engine already ran on a Syncer and reached the daemon only through
SyncHost; the last two links go through it too: upload thumbnails are a
SyncHost call, and the event poll interval is pdfs_sync's constant. The
transfer registry and the shutdown signal, which both sides use, move to
pdfs-core. pdfs-fuse keeps a small sync module: Core's SyncHost impl and
a re-export of the engine.
No behaviour change. pdfs-sync depends on no FUSE or GTK crate.
parse_uid, remote_name_is_safe, node_content_sha1 and media_type_for
move to pdfs-drive next to node_revision_id, the SHA-1 helpers to
pdfs_drive::digest, and now_secs to pdfs_core::timestamp. pdfs-fuse
imports them under their old names. No behaviour change; one step
closer to moving the engine into pdfs-sync.
The engine's methods ran on Core, so a pass could reach any lock in the
daemon. Its state (progress, folder locks, engine health, the channel to
the engine, unscanned and abandoned folders, the event-feed clock) now
lives in SyncParts with the handles it borrows, and what it needs from
the rest of the daemon goes through the SyncHost trait: the activity
feed, listing invalidation, the ancestry walk, mode settling and the
pause state. The engine's methods run on a Syncer, the two together.
No behaviour change. First half of moving the engine into pdfs-sync.
With a name set, the client keeps its own XDG directories, Secret Service
entry, kernel keys and default mountpoint, and leaves the systemd unit
alone. A test account can then sign in without signing the user out.
scripts/live-bench.py uses it to time one edit in a synced folder, from
the write to the new revision on Drive.
The overlap check walked each existing synced folder's ancestry on Drive
and passed on the walk's failure, so one synced folder whose Drive folder
was in the trash failed every later attach with "remote sync folder is in
the trash". The check now walks through the trash, since a trashed folder
keeps its parent and still overlaps the folders above it, and skips a
folder that no longer exists.
When a mirrored file changed on both sides at the same size and Drive
has a digest, the planner now asks for the hash check it already did on
a first sync. An edit whose upload lost its answer then records a new
baseline instead of a conflict copy of itself. Different bytes take the
conflict path as before.
pdfs_core::lockrank::Ranked is a mutex with a rank. In a debug build, a
thread that blocks on a lock while holding one of a higher rank panics,
naming both. The synced-folder locks, shared publication, the inode tree
and the database writer take ranks in the order the code comments
already state: sync folder, publication, state, DB writer. Release builds
check nothing.
pdfs_drive::counted::Counted wraps any DriveApi and records, per method,
how many calls were made, how many failed, and their total and longest
time. The mount wraps its Drive in it before the first call, so the root
lookup counts too. Diagnostics gains drive_calls (serde default, so an
older CLI or daemon still reads the report), and pdfs diagnostics prints
it. A streaming batch call is counted when it starts, untimed.
Daemon::start takes a turn: a daemon started on one test thread waits
while another test thread still has one, so plain cargo test no longer
runs the simulations side by side. A stop that does not end within 60 s,
or a daemon alive after 20 minutes, aborts the mount's FUSE connection,
which the mounting user may do, so a mount that stops answering fails the
test instead of hanging the run.
Third crate seam of 4.0. `sync/model.rs`, `sync/planner.rs` and
`sync/trace.rs` decide and record without doing I/O, so they move into a
new `pdfs-sync` crate that depends only on pdfs-core, pdfs-drive,
pdfs-store and the SDK's node types. The naming of conflict copies moves
with them as `pdfs_sync::naming`. `Applied` and the mtime and size
signature helpers move from `sync.rs` into the model, which uses them.
`node_revision_id` moves to pdfs-drive.
`sync.rs` and `sync/engine.rs` stay in pdfs-fuse until the store and
local-filesystem ports exist. `conflict_path` loses its `cfg(test)`,
which does not reach another crate's tests. No behaviour change.
Second crate seam of 4.0. `DriveApi`, `RevisionRead` and the forwarding
impl for the real client move from `pdfs-fuse/src/drive.rs` to the root of a
new `pdfs-drive` crate. The in-memory `FakeDrive` and the simulation RNG
move under its `sim` feature, which `pdfs-fuse` enables for its tests.
- `is_network_error` classifies Drive's errors and moves with them;
`link` re-exports it.
- `DriveApi::landing`, the drain's test hook, is no longer `cfg(test)`:
a cfg on a trait method does not cross crates. Its default is a no-op and
the drain still calls it only in tests.
- `pdfs-fuse` keeps its paths (`crate::drive`, `crate::sim::fake_drive`)
through re-exports, so no call site changes.
Test counts are unchanged: pdfs-fuse 448 plus pdfs-drive 18 is the 466
pdfs-fuse had before.
First crate seam of 4.0. `pdfs-core/src/db` and `cache.rs` move unchanged
into a new `pdfs-store` crate; `pdfs-core` keeps configuration, the control
protocol and the shared types, and no longer opens SQLite itself.
- `Pin` is a control-protocol type, so it moves to `pdfs_core::control`;
`pdfs_store::cache` re-exports it. The GUI still depends on core alone.
- `Access::as_db_str`/`from_db_str` become public for the store.
- `pdfs-fuse` and `pdfs-cli` depend on `pdfs-store`; imports change from
`pdfs_core::{db,cache}` to `pdfs_store::{db,cache}`.
Test counts are unchanged: pdfs-core 208 plus pdfs-store 277 is the 485
pdfs-core had before.
`Db::read` fell back to the write connection when it could not open a
read-only one, so a read waited behind whatever transaction the writer was
in. It now returns an error; only an in-memory database, which has no
read-only connections, still reads through the writer.
The diagnostics report counted queued operations on a new thread per report
and left it behind after half a second. The supervisor asks every tick, so a
database that did not answer gained a thread per tick. A probe now starts
only when the previous one has returned, and the count is reported as
unknown instead of 0 when it does not come back (B296).
Taking stacks signals every thread of the process, and the handler
allocates. Run inside the shared test process, the watchdog test caught
other sims' daemon threads inside the allocator or holding the database
writer, and those never came back: the sims beside it hung.
Every pass listed the whole mirror folder on Drive to find a few
changes, so a pass over half a million files took hours even when
nothing had changed.
A complete walk of Drive is now kept as the next pass's picture of
Drive (schema 49: sync_walk.complete, sync_remote_dirty). Folders are
marked dirty in two ways:
- the event stream marks the folder a changed node is in now, and the
folder the saved walk last saw it in, since a move names only its
new parent;
- triggers on sync_entry mark the folder of every baseline row a pass
writes, so a pass never relies on the echo of its own change.
A pass loads the picture, lists the dirty folders again (shallowest
first), lists new folders whole, and drops what a folder no longer
holds with everything under it. It then drops the marks it read and
keeps the ones made meanwhile. A folder whose listing failed or came
back short is marked again. The event loop also starts a pass for each
folder it marked, so a change made elsewhere syncs within ten seconds.
The picture is only used when the folder's root is in the account's
own volume, the event stream was read in the last 30 s (a pass right
after a start waits up to 30 s for it), and the last full walk is less
than a day old. ContinuityLost and a new cursor drop every saved walk.
A folder's baseline row was written again on every pass, unchanged,
which would mark its parent every time; it is now written only when it
changes.
Tests: three DB tests for the marks and the listing replacement, and
the sim a_pass_lists_only_the_folders_changed_on_drive. It covers an
edit, a new folder holding a folder, and a deletion, all of which
arrive, and checks that a folder nothing changed in is never listed.
A resize through an open handle recorded the new length and claimed the
grown tail as written before calling set_len on the scratch file, and
ignored its result. A refused grow (full disk) then succeeded, and the
handle described bytes the scratch file never held.
WriteHandle::resize now resizes the scratch file first and records the
length and ranges only on success; setattr answers its error.
The walk of Drive is the slow half of a pass over a large mirror folder.
It used to start over after every stop, so a folder too large to walk
between two restarts never synced.
The walk is now a queue of folders. Each listing is saved, together
with the subfolders it found, in one transaction (schema 48: sync_walk,
sync_walk_dir, sync_walk_item). A pass resumes a saved walk over the
same root that is less than 24 h old, and lists only the folders that
are left. A failed listing is not saved, so the next walk asks for it
again. Planning and the wipe guards still see the whole tree.
A saved listing is never used against a newer baseline. SQLite triggers
drop a folder's saved walk on any change to its baseline other than a
filled-in revision id, and on a change to the folder's path, root or
mode. The pass drops the walk once it is complete, before applying
anything, and fails if that does not work. The push pass drops it as
well. Otherwise a move to another synced folder would leave a listing
that reads the moved file as deleted on Drive.
docs/SYNC_ENGINE.md has the design of the coming state machine and
records why planning and applying are not yet split by subtree.
Each pass over a mirror folder now records how long its stages take
(lock wait, baseline, local walk, remote walk, plan, apply, cleanup).
It also records the count and the total and max time of each kind of
Drive call and applied op, how many items each stage handled, and the
slowest folder listing on Drive.
The trace is logged as "sync: pass trace" when a pass ends, is cut
short or runs longer than 30 s. The running pass and the last pass
over each folder go out in SyncEngineState::traces, which
`pdfs diagnostics` prints.
The new sim test found that a file uploaded by a pass gets a baseline
row without a revision id: Drive does not list the node at once, and
the upload returns only its uid. Since B294, the next pass reads such
a file in full once and records the id.
Issue #53: two folders sat at a month-old `error` while their passes were
cut short at every restart, and the folder after the large one never got
a turn.
- The remote walk stores the revision ids it confirms after each listing,
so a cut-short pass no longer makes the next walk unlock every key again.
- A burst runs named folders first, then the rest smallest baseline first.
- A removal asks the running pass to stop at its next checkpoint and waits
up to a minute instead of blocking a control handler for hours.
- Listing folders copies the progress map instead of holding its lock
across database queries.
- The engine resets folders left `syncing` by a killed daemon to `error`.
- A pass logs a heartbeat every five minutes, its progress when cut short,
and its first failed step when it ends in `error`.
Offer only COPY when dragging rows out, so a file manager can never move
a file out of the mount and delete it from Drive. Decide move or copy
from where the drag came from: rows of this app move, files from a file
manager browsing the mount are copied. Leave out each source that cannot
go to the target instead of failing the batch, skip paths with .., stat
dropped files off the main thread, skip symlinks the daemon does not
upload, restart the placeholder grace while transfers run, and keep
placeholder rows out of share lookups.
Mark the wait for key recovery with a separate awaiting_keys field instead
of a null next_attempt, which an older daemon cannot parse. Pin the
missing-key match against a real rpgp decrypt failure, including the
try-every-key path, and test that a parked daemon pings the watchdog until
it is stopped.
My files did not take part in drag and drop with the rest of the desktop:
- A row dragged out carried an app-internal path string, so a file manager
or any other app got nothing it could use.
- On Wayland a file manager's drag reaches the drop target as MOVE alone
(the action the compositor picked so far, not every action the source
offers). The page answered only to COPY, so the drop was refused with no
message and nothing uploaded.
- Every row took string drops, and a file manager's drag carries text too,
so a drop onto a row was taken by the row and rejected.
Now a row (or the whole selection) drags as a file list under the
mountpoint. Rows decline drops unless they are folders, which take them;
anything else falls through to the page. A drop sorts the dropped paths:
ones inside the mount move through the daemon, the rest upload into that
folder. Outside drags are always answered with COPY, which makes the
compositor pick the copy, so a source never deletes what it handed over.
The Name cell fills its column, so the whole column is the drop zone.
Uploads (dropped, or through Upload Files / Upload Folder) show in their
folder at once as faded placeholder rows until a listing has the real
entry. A placeholder that never arrives goes once nothing is transferring
and it is past a short grace period. Placeholders carry a reserved uid and
cannot be opened, dragged, dropped onto, right-clicked or bulk-selected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A large trash never finished listing, so the Trash page kept the rows of
the last refresh that got anywhere, and Empty Trash listed the trash before
sending the delete and hung there (B293). The paging fix is in
proton-drive-rs 0.12.5.
- The refresh reads only nodes it has not stored yet, without unlocking
file keys, keeps the time the server says each was trashed, and drops
rows only once the whole listing is in.
- Empty Trash sends the delete at once under the trash call time limit
and clears the stored listing. Restore and Delete Permanently drop their
rows right away.
- Schema v47 indexes trash.parent_uid and drops the stored rows once, so
they are read again with real deletion times.
- The Trash page groups items by the folder they were deleted from, opens
deleted folders through the new ListTrashedFolder request, and has a
search box and a switch back to one list. Restore and Delete Permanently
on a folder row act on everything deleted from it.
- pdfs trash takes --by-folder and --folder UID.