Skip to content

ALI-2600: One message per failed copy or move, and undo a copy that fills its destination - #66

Merged
michaelaguiar merged 9 commits into
mainfrom
aliasbot/ali-2600-copy-errors
Dec 4, 2026
Merged

michaelaguiar merged 9 commits into
mainfrom
aliasbot/ali-2600-copy-errors

Conversation

@michaelaguiar

@michaelaguiar michaelaguiar commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Fixes ALI-2600.

When a copy filled its destination, each file left got its own notice in the system's words, for example "e4_8b_pool_ld.upk: Disk quota exceeded", four at a time, with half the folder left behind. Mike decided to keep the "file name: reason" format, to collapse repeats, and to undo a copy that runs out of room, as Finder does.

Behaviour

  • Plainer reasons, by error kind and by which side failed. "File name: reason" stays for a single failure.
    • Full disk or quota: "There isn't enough space in “tmp”, which has 4.2 MB free".
    • Permission: "You don't have permission to change “X”", or "…to read it" or "…to read them".
    • Read-only: "“X” is on a read-only drive".
    • Name: "The name is too long for “X”".
    • Input or output error: "The drive couldn't read or write “name”. It may be failing or have been unplugged".
    • Gone: "“name” is no longer there".
    • Anything else keeps the system's words.
  • One notice per reason. Failures are collected and told when the job ends, and repeats collapse into one notice with a count ("12 files: You don't have permission to read them"). A screen reader hears that one notice. Extract jobs collapse the same way.
  • A space check before starting. For a copy, or a move to another filesystem, the sources are measured first, with each file rounded up to 4 KiB. The total is compared with the smaller of statvfs's free space and the user's remaining quota (quotactl_fd, Q_GETQUOTA), in the new crates/core/src/space.rs. If it won't fit, nothing starts: "“Life Is Strange” needs 11 GB, but “tmp” only has 8.5 GB free".
    • Network places, autofs and FUSE mounts other than fuseblk are skipped, using the same complete::avoided_fs rule as path suggestions, without touching the share.
  • A full destination undoes the job. The first ENOSPC or EDQUOT stops it.
    • It removes the cut-short file, every folder the job created, and each file it added inside folders it merged into.
    • Anything a Replace sent to the Trash comes back. Nothing that was there before is touched.
    • One message: "Couldn't copy “X”: there isn't enough space in “tmp”. Nothing was copied".
  • Moves to another drive copy (and sync) everything first, and delete the originals only once all of it has arrived. If the destination fills, the copies are removed and the originals stay. A source file that changed during the move is kept, with a notice.
    • Before an original is deleted, it's compared with how it looked just before its copy, in one of three ways:
      • Local disks compare the inode, size and mtime.
      • FAT, exFAT and ext3, with mtimes counted in 1–2 s steps, also compare ctime.
      • Shares that renumber inodes (NFS, SMB, sshfs, gvfs and similar, mounts::inodes_renumbered) compare size, mtime and ctime.
    • On FAT, exFAT, ext3 and shares, an original is also kept whenever its mtime is no more than 10 s before that look. The 10 s allows for a server clock that differs from the local one. Keeping is always the safe side.
    • Same-drive renames are counted per top-level item, and progress keeps moving while the originals are deleted.
  • Bench-only seam: GANNET_SKIP_SPACE_CHECK turns the space check off, so an e2e check can fill a disk partway.

Throughput

Home btrfs to /tmp tmpfs, median:

Copy main this branch
2 GB file (9 runs) 405.1 ms 401.9 ms
20,000 files, 79 MB (21 runs) 174.9 ms 173.7 ms

Checks

  • Mike tried a dev build: an 11 GB copy into his /tmp scratch was refused before starting, because his quota is the smaller limit there, and three unreadable files gave one notice.

  • Unit tests pass, with new ones for:

    • each mapped reason and the collapsing;
    • a copy refused before starting, one that fills, a merge that fills (only new files go, and a replaced file comes back), a cross-drive move that fills (the originals intact) and a file changed during a move, on 4 MiB tmpfs disks that scripts/sandbox-run.sh mounts at /run/gannet-small/*;
    • shares and FUSE never asked for space;
    • the three ways of comparing a moved original, and the 10 s window, with fixed times.

    The six behaviour tests fail against main.

  • Clippy: 0 warnings.

  • Sizing counts each file as the smaller of its allocated blocks and its size rounded up to 4 KiB, so sparse and preallocated files are both measured fairly.

  • e2e: all pass, including a_copy_too_big_for_the_disk_never_starts, a_copy_that_fills_the_disk_is_undone_even_in_a_merge and a_move_that_fills_the_other_disk_leaves_the_originals, each of which fails with main's binary. failures_are_visible is updated for the new wording.

  • main (ALI-2632: Hide the host's drives and network shares from the test sandboxes #62, ALI-2599: Suggest folders while a path is typed, with Tab to complete #64, ALI-2601: Format a removable drive from the sidebar #65) is merged in. The only conflict was scripts/sandbox-run.sh, where ALI-2632: Hide the host's drives and network shares from the test sandboxes #62's block is kept and the small disks follow it.

…ills its destination

Copying an 11 GB folder to a nearly full /tmp gave one notice per file left
over, in the system's words ("e4_8b_pool_ld.upk: Disk quota exceeded"), four
at a time. Now a job tells each reason once, and a full destination undoes
the job instead of leaving half a folder behind.

- Plainer reasons, by error kind, keeping "file name: reason" for a single
  failure: no space or quota ("There isn't enough space in “tmp”, which has
  4.2 MB free"), permission (to change the folder written in, or to read the
  item), read-only drive, name too long, I/O error, and gone. Other kinds keep
  the system's words.
- Failures are gathered during the job and told when it ends. Several with
  the same reason become one notice with a count ("12 files: You don't have
  permission to read them"), so a screen reader hears one announcement.
- A copy, or a move to another disk, is measured before it starts. When the
  destination is on another filesystem and not a network share, the size is
  compared with the smaller of statvfs's free space and what's left of the
  user's quota (quotactl_fd, Q_GETQUOTA). If it won't fit, nothing starts:
  "“Life Is Strange” needs 11 GB, but “tmp” only has 6.3 GB free".
- The first ENOSPC or EDQUOT stops the job. Everything it made is removed:
  the cut-short file, each folder it created (with what it put there), and,
  inside folders it merged into, each file it added. What a Replace sent to
  the Trash comes back. Nothing that was there before is touched. One
  message: "Couldn't copy “Life Is Strange”: there isn't enough space in
  “tmp”. Nothing was copied".
- A move to another disk copies everything first and removes the originals
  only once all of it has arrived. If the destination fills, the copies go
  and the originals stay. A file that changed while it was being copied is
  kept, with a notice.
- Extracting several archives that fail the same way is told once too.

Tests: unit tests for each reason, for the grouping, and, on 4 MiB tmpfs
disks that scripts/sandbox-run.sh now mounts, for a copy refused before it
starts, one that fills partway, a merge that fills, and a move that fills.
e2e checks for the same three cases on a 4 MiB tmpfs in the app's sandbox.
GANNET_SKIP_SPACE_CHECK (bench builds only) lets a check fill a disk
partway.

Copy speed, home (btrfs) to /tmp (tmpfs), median of alternating runs:
2 GB file 405.1 ms on main, 401.9 ms here; 20,000 files 174.9 ms on main,
173.7 ms here.
…y-errors

# Conflicts:
#	scripts/sandbox-run.sh
…n avoids

space::is_remote now uses complete::avoided_fs, as the path bar's completion
does: network shares, autofs and FUSE other than fuseblk, never /, and any
mount inside one of them counts as it.
@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 1. The code-review skill ran, and its findings were checked with a hand review of ops.rs and space.rs.

Confirmed fine:

  • no undo path removes anything that existed before the job: merges, empty folders, symlinks, and Replace restored in order;
  • GANNET_SKIP_SPACE_CHECK is bench-only;
  • quotactl_fd usage and statvfs are right;
  • the source-changed check works, and a crash before delete_moved leaves both copies.

Being fixed:

  • P2: the space check can refuse jobs that would fit. It will use allocated size (st_blocks), and skip merges and conflicts, compressed or CoW destinations (btrfs, zfs, bcachefs) and pool-sharing sources. It will refuse only a clear overflow, since rollback covers the rest.
  • P2: cancelling a cross-disk move deleted the originals already copied. A cancel will delete no originals and remove this job's copies: "Nothing was moved".
  • P2: collapsed notices dropped the file names, and the CLI got empty paths. Events will keep the first paths, and the CLI will report each path.
  • P3:
    • ENOENT-only "gone" in delete_moved;
    • bounded failure storage;
    • no space query on shares in reason;
    • doc fixes;
    • mixed-move counts;
    • a full destination on a rename is named and rolled back;
    • wording and plurals;
    • the NOSPC key by full path.
  • Kept, noted in the doc: memory per copied file on huge trees, and a job-made folder removing what another program put in it.

…back, names kept

- The check for room counts the blocks the sources have allocated, not their
  size rounded up, and is skipped when the answer isn't clear: a source's
  name is already in the destination (a merge or a conflict), or the
  destination is on btrfs, zfs or bcachefs (compression, shared or deduped
  blocks), a network share or FUSE. Sources on the destination's device,
  as through a bind mount, still aren't counted. A plain overflow is still
  refused, and only the sources from other devices are counted in "These N
  items need".
- Stopping a move across disks, by Cancel or by the dialog, removes the
  copies it made and deletes no original: "Stopped moving “X”. Nothing was
  moved", in place of "Stopped: Moving…" (Outcome::stopped).
- A collapsed notice keeps the first 5 paths and the count in Event::Error.
  The job keeps a count per reason and those 5 paths, not every failure.
  The command line tells each failure with its own path (Engine::tell_each),
  and an error about no one item has no path.
- Removing the sources of a move: only "not found" counts as gone. Another
  error is reported and the source stays, and isn't recorded as moved.
- A rename that fails with no space is handled as a full destination.
- Asking for free space for the "not enough space" reason skips shares.
- Wording: "It's no longer there" and "couldn't read or write it" after the
  name, "1 on the same drive was moved", and no-space reasons in two folders
  with one name are told apart.
- Module doc notes two known limits: the paths a big move holds until the
  end, and a folder the job made going with what others put in it.
@michaelaguiar

Copy link
Copy Markdown
Member Author

Round 1 fixes are in a8333a4. All 12 done, none declined.

  • P2, the space check: it counts allocated blocks (st_blocks × 512). It's skipped when a source's name already exists in the destination (a merge or conflict), on btrfs, zfs and bcachefs (space::worth_checking), and on shares and FUSE. Sources on the destination's device (bind mounts) were never counted. Tests: merge, sparse file, same device, each skip, and a plain overflow still refused.
  • P2, cancelling a cross-disk move: it removes the copies and deletes no original: "Stopped moving “X”. Nothing was moved" (new Outcome::stopped). Test: cancelled at 30 of 50, all originals present and the destination empty.
  • P2, names: Event::Error carries the first 5 paths and a count. The CLI sets Engine::tell_each for one error per path, and an empty path becomes None. Unit and CLI tests.
  • P3:
    • only ENOENT counts as gone (is_gone), with no Moved step for a source still there (test);
    • failures are bounded to counts plus 5 names (test with 100,000);
    • no space query on shares;
    • doc fixes;
    • mixed-move counts;
    • a full rename goes through copy_failed (untested: ENOSPC on rename couldn't be forced in the sandbox);
    • wording, plurals, and the NOSPC key by full path (test).
  • Noted in the module doc: memory on huge cross-disk moves, and a job-made folder removing what another program put in it.

Throughput, cores 16–31, 11 alternating runs, median:

Copy main this branch
2 GB file 676.1 ms 674.3 ms
20,000 files 398.4 ms 401.9 ms

The 20,000-file difference is inside the run-to-run spread.

Unit tests: 979. Clippy: 0 warnings. e2e passes.

@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 2. The code-review skill ran, and its findings were checked.

Data safety holds:

  • originals are deleted only in delete_moved, after the cancel check;
  • undo_made removes only targets this job created with rename_noreplace, plus Replaced items put back;
  • a full rename can't remove its source;
  • is_gone is used consistently in the new code.

Being fixed:

  • P2: moving off a network share or FUSE mount would keep every original, because those mounts can report a different inode for the same file (mounts::inodes_may_change). Such sources will be compared by size and mtime only.
  • P3:
    • a cancelled same-disk merge will no longer say "Nothing was moved" when files were renamed; this will be based on actual copies;
    • worth_checking runs before any conflict probe, so nothing touches a share;
    • the destination will be resolved against the mount table before the share check;
    • the move's space count stops at nested mounts;
    • a cancel after deleting starts finishes the move and reports it as done.

Also confirmed: hard links are counted per path, which is correct for a copy; conflict-skip is conservative; failure counts are exact past 5; tell_each is CLI-only.

…inside a move

- Removing the sources of a move: on a share or FUSE mount, where inode
  numbers can change between looks (mounts::inodes_may_change), a file is
  known by its size and time alone, so moving a folder off SMB or sshfs
  doesn't keep every original.
- A stopped or full move takes back only what it copied. A merge on one
  disk that was stopped keeps what it renamed, removes the folders it
  emptied, and isn't "Nothing was moved". The count of what moved on the
  same drive is of items renamed, including inside merges, and the folders
  merged into stay selected.
- The check for room asks space::worth_checking before looking for names in
  the destination, so nothing on a share is looked up.
- space::is_remote and worth_checking follow the destination one part at a
  time against the mount table (complete::resolve), so a link to a share
  counts as the share and nothing on it is touched.
- A move or delete doesn't count what's on a disk mounted inside the folder,
  which it leaves where it is.
- A stop that comes once every copy has arrived and the originals are being
  removed finishes the move, which isn't reported as stopped.
@michaelaguiar

Copy link
Copy Markdown
Member Author

Round 2 fixes are in eacfd00. All 6 done.

  • P2, shares: Seen::unchanged compares inode, size and mtime, or only size and mtime for sources on mounts where inodes may change (cifs, nfs, sshfs, fuse*). The mount table is read once per job. Unit test with a fake mount table. There's no e2e, because the sandbox has no FUSE filesystem.
  • P3, same-disk merge cancelled: a stopped move is taken back only if this job made copies (made or Moved::File). A cancelled merge keeps its renames, removes the folders it emptied, and stays selected. Unit test.
  • P3: worth_checking now runs before any conflict probe.
  • P3: the destination is resolved through complete::resolve against the mount table, so a link to a share counts as the share, and nothing inside is looked up. Unit test with a fake that fails on any lookup inside.
  • P3: move and delete scans stop at mount boundaries. Unit test with a disk mounted inside the moved tree.
  • P3: a stop arriving during the deletes finishes them and reports the move as done.

Unit tests: 983. Clippy: 0 warnings. e2e passes.

@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 3. The code-review skill ran over the whole branch, and its findings were checked against eacfd00. No data loss was found.

  • Emptied source folders are removed with a non-recursive rmdir.
  • resolve runs on the job thread, and a destination it can't resolve fails safe as remote.
  • Mount-boundary scans match delete_tree, which already never deletes into a mounted disk.
  • No original is deleted without a verified, synced copy.

Being fixed:

  • P2: the "loose" comparison (size and mtime) for share sources lets a same-size rewrite within one mtime tick through. It will also compare ctime, keep the original when its mtime is within 2 s of when it was seen or of the job start, and apply only to mounts that really renumber inodes (not fuseblk).
  • P3:
    • "N on the same drive were moved" counts top-level items only;
    • the cancel flag is read once in settle;
    • progress ticks during the final removals;
    • sizing uses min(blocks × 512, size rounded to 4 KiB), for preallocated files;
    • loose_inodes is computed only once a cross-disk copy is made.

…rogress while removing

- A source on a share whose inode numbers change between looks is now told
  apart by its size, its modification time and, where the share keeps one,
  its change time. One changed within 2 s of being copied or of the job
  starting is kept, as a change that close can leave the times the same.
- Which mounts count as such shares is mounts::inodes_renumbered: network
  filesystems and network FUSE (sshfs, gvfsd-fuse, rclone and the like),
  not fuseblk, exFAT or other local FUSE, whose inode numbers are stable.
  It's worked out only once a top-level item is copied, not for renames.
- "N on the same drive were moved" counts top-level items only.
- Removing a move's sources counts in its progress, so the bar doesn't sit
  at the end meanwhile.
- A file counts toward the room it needs as the smaller of its allocated
  blocks and its size rounded up to 4 KiB, so neither a sparse file nor one
  with reserved space is over-counted.
@michaelaguiar

Copy link
Copy Markdown
Member Author

Round 3 fixes are in b51bfa6.

  • P2: sources on shares that renumber inodes must match size, mtime and ctime (ctime is skipped where it's reported as 0). The original is always kept if its mtime is within 2 s of the copy or of the job start. "Loose" is a new, narrower mounts::inodes_renumbered (nfs, cifs, smb3, 9p, ceph, sshfs, gvfsd-fuse, rclone, s3fs and so on), which leaves fuseblk, exFAT and other local FUSE strict. Two unit tests.
  • P3:
    • "N on the same drive were moved" counts top-level items;
    • the cancel flag is read once in settle;
    • progress ticks during the final deletes;
    • sizing uses min(blocks × 512, size rounded to 4 KiB);
    • loose_inodes is computed lazily on the first real copy.

Unit tests: 984. Clippy: 0 warnings. e2e passes.

@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 4 (by hand, a narrow check of b51bfa6's share comparison). Confirmed fine: ctime reported as 0 and future mtimes fail safe; the window is in the keep direction; the lazy loose_inodes is always computed before a file is queued.

Being fixed:

  • P2: the 2 s window was anchored on the time after the copy, not the moment the source was read. It will be anchored before the copy, at the earlier of that and the job start.
  • P2: share timestamps come from the server's clock, so skew over 2 s defeated the window. For share sources it widens to 10 s either side, and a source mtime at or after the reference minus 10 s is always kept. Skew beyond 10 s is documented.
  • P3: coarse local filesystems (vfat, exfat, ext3) also compare ctime and get the window.
  • P3: more network types join inodes_renumbered (glusterfs, ceph-fuse, davfs, MTP FUSE, afs, lustre, vboxsf). A missing type is strict, which is the safe direction.

…e its copy

- The reference time for telling whether a moved source changed is taken
  right before it's looked at, ahead of the copy, or the job's start if
  that's earlier (reference_time).
- On a share, times come from the server's clock, so a file whose time is
  at or after 10 s before the reference is taken as changed and kept. That
  covers a server up to 10 s behind, and any amount ahead. Beyond 10 s
  behind, only the size and change time can tell, as the doc says.
- Local disks with coarse times (vfat, exFAT and msdos at 2 s, ext3 at 1 s)
  compare the change time too, where it's kept, and use the same window.
  Care::{Strict, Coarse, Loose}, from the mount table the move reads once.
- mounts::inodes_renumbered also takes in fuse.glusterfs, fuse.ceph-fuse,
  fuse.davfs, the MTP FUSE kinds, afs, lustre and vboxsf. Plain fuse stays
  out, and so is compared strictly.
@michaelaguiar

Copy link
Copy Markdown
Member Author

Round 4 fixes are in ea33bb1.

  • P2: the reference time is taken right before smeta is read, before the copy, and is the earlier of that and the job start (reference_time). Test with fixed times.
  • P2: for share sources, an mtime at or after the reference minus 10 s counts as changed, and the original is kept. That covers a server up to 10 s behind and any amount ahead. The limit is in Seen::unchanged's doc. Test at ±10 s, +3600 s and −11 s.
  • P3: a new Care { Strict, Coarse, Loose }. Coarse (vfat, exfat, msdos, ext3) keeps the inode check, adds ctime and uses the 10 s window. Strict local disks are unchanged. Tests.
  • P3: inodes_renumbered adds glusterfs, ceph-fuse, davfs, the MTP FUSE types, afs, lustre and vboxsf. Plain fuse stays strict.
  • Visible effect: moving off FAT, exFAT, ext3 or a share keeps the original, with a "changed" notice, when the file was modified within 10 s before the move or any time during it. That errs toward keeping.

Unit tests: 986. Clippy: 0 warnings. e2e passes.

@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 5 (by hand, narrow check of ea33bb1): no P1 or P2. The Strict path for local fine-time disks is unchanged. Coarse only tightens. Loose keeps a superset of what it kept before under a forward-moving clock, and the time arithmetic can't panic.

Declined, both very narrow:

  • P3: the newly listed share types compare without the inode, so a same-size replacement with an identical preserved mtime, on a filesystem that reports no ctime, would pass. Those filesystems renumber inodes, which is why they're loose.
  • P3: a backwards wall-clock step of more than about 8 s during a copy can move the reference past a just-stamped mtime.

…s its names in

CI lists names in another order than the btrfs scratch disk here, and both
failed there.

- a_full_merge_takes_away_only_what_it_added answers every clash with
  Replace for all, however many come up before the disk fills, instead of
  expecting three questions.
- stopping_a_merge_on_one_disk_keeps_what_it_renamed gives each merged
  folder one thing and stops at a second source, which place_all reaches
  after the first, so the questions come in one order on any disk.
@michaelaguiar

Copy link
Copy Markdown
Member Author

CI passes on 7be03ad. The two merge tests depended on the order a folder lists its names in, which differs on CI's filesystem. They no longer do, and no behaviour changed. Review is clean after five rounds (the last two narrow, on the move-safety logic). The body now describes how moved originals are compared.

@michaelaguiar
michaelaguiar marked this pull request as ready for review December 4, 2026 07:13
@michaelaguiar
michaelaguiar merged commit 90b484e into main Dec 4, 2026
3 checks passed
@michaelaguiar
michaelaguiar deleted the aliasbot/ali-2600-copy-errors branch December 4, 2026 15:56
@michaelaguiar michaelaguiar mentioned this pull request Dec 4, 2026
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.

1 participant