mirror.rs keeps a pass from end to end (reconcile_folder, reconcile_pass,
do_reconcile), the trace, the helpers the parts share, and the tests.
Syncer's methods move, unchanged, into:
- mirror/walk.rs: walking the local tree and Drive's folders, resuming
a saved walk, walking only the changed folders, listing one (8)
- mirror/apply.rs: applying a plan in batches, uploads, downloads, and
the baseline each one leaves (12)
- mirror/push.rs: the push pass (1)
No behaviour changes.
photos.rs keeps the image, RAW and video decoding, the decode budget,
PhotoJobs and the tests. Core's methods move, unchanged, into:
- photos/thumbs.rs: generating and uploading missing thumbnails, file
thumbnails, folder covers, the recursive build (19 methods)
- photos/timeline.rs: the timeline, favorites, duplicates and similar
shots, places, on this day, groups, trashing photos (21 methods)
Two doc links in drain/revision.rs point at crate:: instead of super::.
No behaviour changes.
drain.rs keeps the workers, the claim and dispatch of an op, the access
deferral, the helpers several op kinds share, and the tests. The Core
methods that drain one kind of op move, unchanged, into submodules:
- create.rs: creates and mkdirs, twins left by an unanswered attempt,
adopting the real uid (16 methods)
- rename.rs: renames and moves (3)
- trash.rs: trashes, and withdrawing a create that never landed (5)
- revision.rs: uploads, the conflict check, placing what landed, the
revision debounce (13)
The source-order tests read the drain through DRAIN_SOURCE. No behaviour
changes.
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.