Skip to content

[ai] trash: Cache directory content size before deletion - #4745

Open
carrerasdarren-cell wants to merge 1 commit into
TeamAmaze:release/4.0from
carrerasdarren-cell:fix/trash-directory-metadata-size
Open

carrerasdarren-cell wants to merge 1 commit into
TeamAmaze:release/4.0from
carrerasdarren-cell:fix/trash-directory-metadata-size

Conversation

@carrerasdarren-cell

Copy link
Copy Markdown

Fixes: #4326

Description

A directory's filesystem entry length does not represent the bytes in its contents. Cache the existing recursive folderSize(context) result when creating trash metadata, before the source is moved. Regular files keep the existing length calculation, and the trash listing can continue reading the cached value without rescanning.

Issue tracker

Matches the maintainer's requested metadata fix.

Automatic tests

  • Added unit tests for specific individual functions
  • Added headless tests for the changed metadata behavior
  • Added emulator tests for new UI elements — no UI elements changed

The three new regressions cover nested contents totaling 4,156 bytes, an empty directory, and unchanged regular-file size/name/path/type. Against the original production code, the regular-file controls passed, while directory cases reported 128 instead of 4,156 bytes and 64 instead of zero. The original run had five assertion failures, three passes and one case skipped by the existing fail-fast policy.

  • ./gradlew :app:testFdroidDebugUnitTest --tests com.amaze.filemanager.filesystem.HybridFileTest — 39 passed, zero failed or skipped, across the class's three configured SDK variants (21/28/30).

These were actual project/Robolectric runs with synthetic local files. An external Gradle init script limited the run to one worker/test fork and directed reports/temp files to the SSD; it did not remove owner tasks, dependencies or the fail-fast policy.

Manual tests

  • Done — device/emulator UI workflow was not exercised; validation above is headless metadata behavior.
  • Device: macOS ARM64 build host; no Android device claim.
  • OS: JDK 17, Android SDK 34, NDK r28c; Rust 1.95 with the four configured Android targets.

Build tasks success

  • ./gradlew assembleDebug — F-Droid and Play debug APKs produced, including the configured native targets.
  • ./gradlew spotlessCheck

Both commands exited successfully. Existing upstream resource/deprecation and formatter warnings remain in the logs; this change leaves the build configuration and unrelated sources untouched.

Generative code

  • This PR used generative code tools (GenAI, LLMs, etc.)
  • Model: Codex assistance; exact underlying model identifier is not exposed in this runtime.
  • Version: Not exposed in this runtime.
  • Provider: OpenAI.

Codex assisted implementation, actual test execution and review. AI review is not represented as human validation.

Store the recursive content size when creating a directory trash
entry, rather than its filesystem entry length. Reuse the existing
folder-size helper and retain the regular-file metadata behavior.

Add headless regressions for nested and empty directories and a
regular-file control. The original code fails the directory cases;
all 39 HybridFileTest cases pass with the fix. Debug assembly and
Spotless checks also pass. Codex assisted this contribution.

Fixes TeamAmaze#4326.
@carrerasdarren-cell
carrerasdarren-cell force-pushed the fix/trash-directory-metadata-size branch from 1fc212e to 4d9b576 Compare October 20, 2026 00:49
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.

Trash displays folder sizes incorrectly

1 participant