Skip to content

feat: add optional permanent delete (Trash) support - #30

Open
jimisola wants to merge 3 commits into
ghotso:mainfrom
jimisola:feat/permanent-delete-trash
Open

jimisola wants to merge 3 commits into
ghotso:mainfrom
jimisola:feat/permanent-delete-trash

Conversation

@jimisola

@jimisola jimisola commented Jun 14, 2026 •

Copy link
Copy Markdown

Implements the scope proposed in #29.

Summary

  • New permanent_delete option (default false, current behavior unchanged).
  • When enabled, async_delete_backup calls trash_clear on the deleted backup and metadata file ids after deletefile, permanently purging them from pCloud Trash and freeing quota immediately.
  • trash_clear failures are tracked per file (backup/metadata); if either fails, the delete still succeeds (matching the existing metadata-delete error handling style) but logs a warning that the backup may still be recoverable in Trash, rather than silently logging "Successfully deleted".
  • _async_trash_clear validates the file id before calling trash_clear.
  • Exposed as a checkbox in both the initial setup (folder/options step) and the integration's Options flow, with English and German strings, and an explicit warning that enabling it makes deletions unrecoverable.
  • PRD/PRD.md updated to document the optional trash_clear step.

Files changed

  • custom_components/pcloud_backup/const.py — CONF_PERMANENT_DELETE / DEFAULT_PERMANENT_DELETE
  • custom_components/pcloud_backup/api.py — async_trash_clear(file_id)
  • custom_components/pcloud_backup/backup.py — async_delete_backup + _async_trash_clear helper
  • custom_components/pcloud_backup/config_flow.py — shared options schema + both flow steps
  • custom_components/pcloud_backup/strings.json + translations/{en,de}.json
  • PRD/PRD.md

Test plan

  • Manual: with permanent_delete=false (default), delete a backup — confirm it lands in pCloud Trash as before.
  • Manual: with permanent_delete=true, delete a backup — confirm deletefile succeeds and the same file id is then purged from Trash (trash_clear), freeing quota immediately.
  • Manual: toggle the option via Settings → Devices & services → pCloud Backup → Configure, confirm it persists and reload applies it.
  • No automated test suite exists in this repo yet; happy to follow up with pytest-homeassistant-custom-component coverage for this (and other) areas in a separate PR if useful.

Note on the German translation

I'm not a native/fluent German speaker — the translations/de.json strings were drafted to the best of my ability (and machine-assisted) but please treat them as a starting point. Happy to update if you or another reviewer can suggest better wording.

jimisola added 2 commits June 14, 2026 16:15
Adds a permanent_delete option (default false, preserving current
behavior). When enabled, async_delete_backup also calls trash_clear
on the deleted backup and metadata file ids after deletefile,
permanently purging them from Trash and freeing quota immediately.

Closes ghotso#29
- async_delete_backup now tracks whether trash_clear succeeded for the
  backup and metadata files and logs a warning (instead of a misleading
  "Successfully deleted") if permanent purge failed for either.
- _async_trash_clear logs which file (backup/metadata) failed to purge
  and validates file_id before calling trash_clear.
- Clarify in strings.json/translations that enabling permanent_delete
  makes deletions unrecoverable.
@ghotso
ghotso self-requested a review June 15, 2026 07:17
@ghotso

ghotso commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Thanks - overall this looks good and matches #29.

Please address before merge: inline comments on backup.py (warning text) and de.json (copy).

No action needed from you: I’ll extend permanent_delete to the other existing deletefile paths, do related cleanup, and refresh the README in a follow-up on my side after merging your PR.

Thanks for your contribution and help 🥳

@ghotso ghotso added the enhancement New feature or request label Jun 15, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

purge_failed can be true when only metadata trash_clear fails, after the backup file was already purged. This message then wrongly implies the backup itself may still be in Trash.

Please broaden to something like: "…permanently purging one or more related files from pCloud Trash failed…"

Optional: log which part failed (backup vs metadata) — _async_trash_clear already has file_kind.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick DE polish before merge:

Speicherplatz instead of Kontingent
Label: dauerhaft/endgültig löschen reads clearer than Papierkorb überspringen
Please use the same polished label/description in both folder_path and options.init (they’re duplicated on purpose).

@ghotso

ghotso commented Jun 20, 2026

Copy link
Copy Markdown
Owner

@jimisola Are you still working on this PR? Any updates?

- Broaden purge-failed warning to "one or more related files" to avoid
  implying the backup itself is still recoverable when only the metadata
  trash_clear failed (per ghotso review comment).
- DE label: "Backups dauerhaft löschen" (clearer than Papierkorb überspringen).
- DE description: "Speicherplatz" instead of "Kontingent" (more natural).
@jimisola

Copy link
Copy Markdown
Author

Hi Michael, thanks for the feedback and for the kind words! Just pushed a follow-up commit (13890c2) addressing both:

  • Warning message: broadened to "permanently purging one or more related files from pCloud Trash failed" so it doesn't falsely imply the backup itself is still recoverable when only the metadata purge failed.
  • German copy: label → "Backups dauerhaft löschen", description → "Speicherplatz" instead of "Kontingent", consistent across both folder_path and options.init.

Looking forward to your other improvements on the permanent_delete paths — and happy to help with test coverage whenever you're ready. 🙂

@jimisola

Copy link
Copy Markdown
Author

Is the PR ok?

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ [Feature]: Add optional permanent delete (Trash) support for backup cleanup

2 participants