Skip to content

feat(ui): flush removable drives before unmount and copy success - #1193

Merged
l0gicgate merged 4 commits into
lgse:mainfrom
wmfeht:feat/1182-safe-drive-unmount
Sep 23, 2026
Merged

l0gicgate merged 4 commits into
lgse:mainfrom
wmfeht:feat/1182-safe-drive-unmount

Conversation

@wmfeht

@wmfeht wmfeht commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Removable Unmount, Eject, and the unmount half of encrypted Lock flush the local mount with syncfs on a worker, then run the existing GIO call. The browser leaves that volume before the flush so directory monitors are dropped, and returns only if the release fails while the volume is still mounted. The drive stays in the sidebar, with a progress spinner, until the operation finishes. Hide, Close, and Escape dismiss only the overlay. Success says the drive can be unplugged only when it is removable or ejectable.

A copy onto removable media shows “Writing to device…” and does not report success until syncfs returns. A cross-volume move, replace, merge, or undo syncs that filesystem after the copy and before the source is deleted. If the flush fails, the source stays in place. Cancelling or failing after bytes were written still flushes those roots, and a cancel does not report the transfer as finished.

Visual evidence

Large copy and move operations to devices such as USB sticks now show real progress bars instead of hiding progress after the data is accepted but a write is still underway:
image

While writes are still finalizing, a modal displays the status correctly:
image

If a write is pending to the drive not initiated by Strata and the device is ejected, a popup notifies the user:
image

If dismissed, the device persists in the side bar with a spinner until operations are finalized:
image

How to test

  1. Mount a removable drive, copy a file onto it, and choose Unmount or Eject.
  2. While the overlay is up, choose Hide and keep using the window. The drive row should keep spinning and should stay listed until the operation finishes.
  3. If the overlay is still open when unmount or eject of a removable drive succeeds, it should retitle to “Safe to remove”. Lock, and unmount of a non-removable volume, should not use that title.
  4. Copy a file onto the removable drive and watch the copy dialog. It should show “Writing to device…” before the copy is reported done.
  5. Move a file from an internal disk onto the removable drive. The original should remain until the writing phase finishes, and should stay if that flush fails.

Expected result: The drive is not dropped from the sidebar while writes are still flushing, Hide does not cancel the operation, a removable copy or move is not reported successful before syncfs returns, and a failed flush does not delete the only remaining copy.

Related issue

Closes #1182

Wait for syncfs on a worker, then the existing GIO unmount, eject, or
lock, before a removable volume leaves the sidebar. Hide only closes the
progress overlay. Copies and cross-volume moves onto removable media sync
that filesystem before success, and a move keeps the source when the flush
fails.

Closes lgse#1182
@wmfeht
wmfeht force-pushed the feat/1182-safe-drive-unmount branch from 3e4b978 to db6acce Compare September 23, 2026 02:05
@l0gicgate
l0gicgate marked this pull request as ready for review September 23, 2026 05:06
@l0gicgate
l0gicgate merged commit 6911908 into lgse:main Sep 23, 2026
22 checks passed
@wmfeht

wmfeht commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator Author

Code review

  • Verdict: approve-with-comments
  • Head SHA: 455cb141217c610cd4a34c02052da1b233cb153a
  • Agent id: bc-29001ab4-ff08-5a5b-ac9c-76f791d33620

Blockers

None.

Nits

  • release_error_is_quiet in src/ui/window/device_release.rs treats any glib::Error whose message contains "aborted" as quiet. IOErrorEnum::Cancelled and FailedHandled already cover handled cancellations. A failed unmount whose text includes that word clears the pending row and shows no dialog.
  • device_matches / keys_match are false when unix device, uuid, and mount root are all missing, so a key does not match itself. Display name is unused. remove_release and hide_release then leave the pending row and header spinner in place. A single shared id is also enough, so a second device that shares only a uuid or mount root is treated as the same release.
  • Cross-volume move, replace, and merge call flush_removable_destination before deleting the source and emit no FlushingToDevice. The copy dialog stays on the byte percentage through that flush. FlushingToDevice comes later from flush_removable_writes, after the source is already gone, and runs a second syncfs.
  • blocking_join_message is copied in src/adapters/local_operations.rs and src/ui/window/device_release.rs.
  • The in-progress release overlay always uses RELEASE_BODY ("Do not unplug it"), including unmount of a volume that is neither removable nor ejectable. Success already withholds "Safe to remove" unless the drive is removable or ejectable.

Notes

Unmount, eject, and the unmount half of Lock call syncfs on a worker, then the existing GIO future, without MountUnmountFlags::FORCE. Hide, Close, and Escape only set dismissed. A cancel that arrives while a removable copy is flushing is reported as Cancelled after syncfs returns, and Pasted is not emitted.

The browser leaves the volume before the flush. After a flush or GIO failure, the previous location is restored when that root is still a mount point and the browser is still on the location it moved to. A navigation the user made during the operation stays where they left it.

Removable copy roots are selected when the mountinfo mount point equals a GIO mount root whose drive is removable or has removable media. When those paths differ, the copy skips syncfs and emits Pasted. Same-filesystem renames report success without waiting for syncfs.

Added tests cover distinct failure modes: flush-before-delete for move, replace, merge, and undo; cancel before the flush and cancel once FlushingToDevice has started; sidebar retention; worker-thread syncfs; restore after a failed flush or a failed GIO call; and the "Safe to remove" title. No excessive or tautological tests.

CI was green at review time (mergeable_state: behind). This review did not re-run it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(operations): copy to USB reports done before data is written; unmount shows no "still writing" state (silent data loss)

2 participants