Skip to content

Conversation

@backportbot-libresign
Copy link

Backport of PR #6347

Add optional boolean parameter 'deleteFile' (default true) to the
DELETE endpoint. This allows clients to control whether physical
files should be deleted from Nextcloud or only the LibreSign
metadata should be removed.

Signed-off-by: Vitor Mattos <[email protected]>
Implement the deleteFile parameter in FileService::delete() method:
- When deleteFile=true: remove physical files and empty parent folders
- When deleteFile=false: keep physical files, only remove metadata

Add deleteEmptyFolder() private method that safely checks and removes
empty folders after file deletion. This prevents accumulation of empty
directories while handling permission errors gracefully.

The deletion is propagated to child files when deleting envelopes.

Signed-off-by: Vitor Mattos <[email protected]>
Update files store to send deleteFile parameter as query param when
the user chooses to delete files. This connects the UI checkbox to
the backend parameter, allowing users to control whether files are
deleted from Nextcloud or only the signature request is removed.

Signed-off-by: Vitor Mattos <[email protected]>
Add comprehensive unit tests for the new deletion features:
- testDeleteRemovesEmptyFolder: validates empty folders are deleted
- testDeleteKeepsNonEmptyFolder: ensures folders with files are kept
- testDeleteWithoutDeletingFile: verifies metadata-only deletion

Refactor test setup to use setUp() method for mock initialization,
eliminating duplicate mock creation across tests.

Signed-off-by: Vitor Mattos <[email protected]>
Signed-off-by: Vitor Mattos <[email protected]>
@github-project-automation github-project-automation bot moved this to 0. Needs triage in Roadmap Jan 6, 2026
@backportbot-libresign backportbot-libresign bot added this to the Next Patch (32) milestone Jan 6, 2026
@vitormattos vitormattos merged commit 5034534 into stable32 Jan 6, 2026
62 checks passed
@vitormattos vitormattos deleted the backport/6347/stable32 branch January 6, 2026 13:23
@github-project-automation github-project-automation bot moved this from 0. Needs triage to 4. to release in Roadmap Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 4. to release

Development

Successfully merging this pull request may close these issues.

2 participants