Skip to content

[ai] trash: Preserve encrypted-file metadata through restore. - #4752

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

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

Conversation

@carrerasdarren-cell

Copy link
Copy Markdown

Fixes: #4730

Description

Deleting a .aze file to Trash currently removes its stored entry, so restoring the intact ciphertext cannot reopen the password prompt. Move the entry's path with the file into and out of Trash, retaining its ID and password. Keeping the entry at the bin path also lets a newly encrypted file use its original path without selecting the old file's password.

Only successful permanent deletion clears metadata. Trash purges clear the physical bin path, including the direct cleanup entry point; failed restores retain both files and their separate entries. If a metadata move fails after a rename, attempt to roll back the rename and report failure; propagate the error if rollback also fails. No encryption algorithm, database schema, permission, or new UI is changed.

Issue tracker

Fixes #4730.

Automatic tests

  • Added unit tests for specific individual functions
  • Added headless tests for the file lifecycle
  • Added emulator tests for new UI elements — no new UI elements

The Robolectric tests use actual synthetic files, Room rows, Trash callbacks, the restore view model, production password-entry selection, and encryption/decryption byte round-trips. They cover row ID preservation, replacement-file password selection before/after purge, occupied restore, failed rename, metadata-error rollback, lightweight moves and plain-file isolation. Android key/password support and remote filesystem controls use the repository's existing test shadows; the injected metadata-write error is explicitly synthetic.

  • ./gradlew :app:testFdroidDebugUnitTest --tests '*DeleteTaskEncryptedMetadataTest' --tests '*SmbDeleteTaskTest' --tests '*SshDeleteTaskTest' — 45 passed, 0 failed/skipped (33 new lifecycle cases + 12 existing remote-delete cases across API 21/28/30)

The commands used one Gradle worker, no parallel execution, an external JVM/module/report/temp-directory guard and existing SSD caches. No owner build/test/dependency settings or assertions were disabled.

The initial regression on unmodified 94afab32b0a1bd0ddbc582978aca9ffced1301b8 failed at the missing metadata assertion after real Trash/restore while restored ciphertext bytes matched. Scope is individual .aze files; this does not introduce a recursive directory-metadata migration or claim a filesystem/database transaction.

Manual tests

  • Done

  • Device: No physical-device or emulator testing performed

  • OS: Headless Android API 21, 28 and 30 under Robolectric; host macOS arm64/JDK 17

Build tasks success

  • ./gradlew assembleDebug — F-Droid and Play debug APKs built
  • ./gradlew spotlessCheck

Generative code

  • This PR used generative code tools (GenAI, LLMs, etc.)

  • Model: OpenAI Codex (coding assistant)

  • Version: Exact model/build identifier is not exposed to this task

  • Provider: OpenAI

Implementation, test preparation and static review used Codex assistance. Validation above records actual local commands/results; AI review is not represented as human review.

Recoverable deletion removes the stored entry needed to reopen an
Amaze-encrypted file. Track its actual bin path and restore the same
entry identity on a successful restore, so a new file at the original
path keeps its own password record.

Finish path updates in the worker before reporting rename success.
Roll back a failed metadata move when possible, and only clear the
physical path after permanent deletion succeeds. Keep failed moves,
restore collisions and unrelated plain-file operations intact.

Verify real synthetic-file lifecycle and Room row state across
Android API 21, 28 and 30, including replacement password selection.

Fixes TeamAmaze#4730.
@EmmanuelMess

Copy link
Copy Markdown
Member

@carrerasdarren-cell please be aware that we have a shortage of review time, so these PRs will sit until we have time to review them. You can better spend your time reviewing and testing already made PRs.

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.

Encrypted .aze file cannot be decrypted after it is deleted to the Trash Bin and restored

2 participants