Skip to content

fix(adapters): recognize already-removed items when emptying Trash - #2093

Merged
l0gicgate merged 4 commits into
lgse:mainfrom
mvanhorn:fix/1854-empty-trash-confirm-deleted-items
Nov 8, 2026
Merged

l0gicgate merged 4 commits into
lgse:mainfrom
mvanhorn:fix/1854-empty-trash-confirm-deleted-items

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Description

Emptying the Trash can report failures for items that were actually deleted. On an ntfs3 volume, 22 of 150 trashed items were reported as failed after all 150 were gone. Every error from deleting a trash child was counted as a failure, including errors returned after the item was already gone. NotFound was not treated as success, and a generic failure was not followed by a check that the child was still present, so the failure count stayed above zero and the partial-failure report appeared.

A failed delete is now counted as deleted when the error is NotFound, or when it is not cancellation and a follow-up query of the child returns NotFound. Any other error still counts as a failure, and up to eight error messages are kept, so an item that is still present remains a failure. Tests cover an already removed file for both NotFound and a generic failure, and errors where absence is not confirmed.

Visual evidence

No user-visible surface changes in this PR, so there is nothing to show.

How to test

The test result for the strata EmptyTrashOutcome change was not available when this description was written.

Related issue

Closes #1854

AI was used for assistance.

A failed delete is now counted as deleted when the error is NotFound, or
when it is not cancellation and a follow-up query of the child returns
NotFound. Any other error still counts as a failure, and up to eight
error messages are kept, so an item that is still present remains a
failure. Tests cover an already removed file for both NotFound and a
generic failure, and errors where absence is not confirmed.

Fixes lgse#1854
@github-actions github-actions Bot added the fix label Nov 8, 2026
@l0gicgate l0gicgate changed the title fix(adapters): Recognize already-removed items when emptying Trash fix(adapters): recognize already-removed items when emptying Trash Nov 8, 2026
Pulls the NotFound/probe condition out of record_deletion into a predicate and notes why a failed delete is probed.
Each row now fails under a distinct mutation of already_removed. Drops the double-delete axis, which no mutation of the NotFound short-circuit could fail, the dangling-symlink row (GIO falls back to lstat for broken links, so it never guarded NOFOLLOW_SYMLINKS), the GIO premise probe, and fixture-existence assertions that record_deletion cannot affect. Present-directory failures stay owned by deletion_caps_errors_and_still_processes_successful_siblings.
@l0gicgate

Copy link
Copy Markdown
Contributor

Review and cleanup

Merged main at afa70b348. No conflicts.

Title. It failed Metadata policy because the description must start lowercase. Retitled to fix(adapters): recognize already-removed items when emptying Trash.

Review against the description and #1854. Confirmed: a failed delete now counts as deleted when the error is NOT_FOUND, or when it is not CANCELLED and a NOFOLLOW_SYMLINKS probe of the child returns NOT_FOUND. Items that are still present stay failures, and the 8-message cap is unchanged. This matches the fix direction in the triage comment on #1854, and deletion_caps_errors_and_still_processes_successful_siblings still holds (12 non-empty directories → 12 failures). There were no earlier review comments.

Fixes pushed

  • 0025d98ea refactor(adapters): name the already-removed check when emptying Trash. The NOT_FOUND/probe condition was an || chain with an .await inside it, nested in record_deletion. It is now the already_removed predicate, with a one-line note on why a failed delete is probed. CodeScene for src/adapters/trash.rs goes from 9.24 on main (Bumpy Road, Deep Nesting) to 10.0.
  • fd0779b18 test(adapters): fold trash absence cases into one table. The two new tests are replaced by delete_errors_count_as_deleted_only_when_absence_is_confirmed. Each row fails under a different mutation of already_removed (all checked locally):
    • missing + FAILED → deleted (fails if the probe is removed)
    • missing + CANCELLED → failed (fails if the cancellation guard is removed)
    • present/child + FAILED → failed (fails if any probe error is treated as absence)
    • present + FAILED → failed

Tests removed

  • The double_delete axis of delete_error_after_removal_counts_as_deleted. Removing the NOT_FOUND short-circuit can't fail it, because the probe reaches the same result for a gone file.
  • The dangling symlink row. GIO falls back to lstat for a broken link, so the row still passes with NOFOLLOW_SYMLINKS removed. It only repeated the present case.
  • The directory row. Present-item failures through the full loop are owned by deletion_caps_errors_and_still_processes_successful_siblings.
  • The GIO premise probe, and the asserts that fixture files still exist (or are gone). record_deletion never touches the filesystem, so those asserts could not fail.

Validation

  • ./scripts/test-headless.py adapters::trash::: 5 passed (before the final rustfmt-only change)
  • ./scripts/quality.sh fmt, ./scripts/quality.sh clippy: clean
  • Not run: QA scenarios (none cover Empty Trash) and a real ntfs3 run. This host can't mount ntfs3 either, so the end-to-end gvfs-on-ntfs3 case is still unconfirmed, as the triage noted.

Follow-ups outside this PR

CI: all checks green as of 2026-11-08 19:14 UTC (QA scenarios is dispatch-only and skipped on PRs).

@l0gicgate
l0gicgate merged commit 4f4dc17 into lgse:main Nov 8, 2026
11 checks passed
@mvanhorn

mvanhorn commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging this, @l0gicgate. Good to have Empty Trash stop reporting already-removed items as failures.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(trash): Empty Trash on ntfs3 reports failures for deleted items

2 participants