protonfs.commands.trash module¶
Inspect and empty Proton Drive’s trash (#70, M6.2).
rm puts things INTO trash and restore pulls them back out, but neither lets a user see what is in trash or empty it – and proton-drive >= 0.5.0 resolves /trash paths by name with first-match-wins (#56), so stale same-named entries can silently make restore refuse to act. trash list surfaces that ambiguity directly (same-name duplicate counts); trash empty wraps the account-global, irreversible filesystem empty-trash behind an explicit typed confirmation.
Deliberately out of scope: selective/per-item permanent deletion from trash by UID – proton-drive does not accept UIDs for /trash paths (see #56’s analysis and the duplicate-basename guard in commands/rm.py), so there is no safe way to target a single item there yet.
Added in version 1.0.0.
- protonfs.commands.trash.empty_trash(ctx, confirmed, reporter=None)[source]¶
Permanently empty /trash for the whole account. Irreversible, and NOT scoped to this repo’s remote_root – it empties every trashed item on the account, not just ones protonfs put there. Requires the user to type an exact confirmation phrase unless confirmed (–yes) is set.
- Parameters:
ctx (
RepoContext) – the loaded repo context.confirmed (
bool) – skip the interactive typed confirmation (the--yesflag).reporter –
Reporterto narrate progress through; defaults to the process reporter (get_reporter()).
- Return type:
- protonfs.commands.trash.list_trash(ctx, console)[source]¶
Render every item in /trash: name, type, original parent path and duplicates.
The parent comes from
resolve_parents()(an honest marker when it can’t be resolved). The duplicate column counts how many OTHER trashed items share the name, which is exactly the ambiguity restore warns about (#56): proton-drive would act on the first name-match, not necessarily this one. :rtype:NoneChanged in version 3.4.0: The original parent is a resolved path (was always
?, #231).
- protonfs.commands.trash.resolve_parents(ctx, entries)[source]¶
Map each
parentUidin a /trash listing to a human-readable original parent.proton-drive cannot resolve a bare UID, so this works from what can be known: the account root and the repo’s
remote_root(onefilesystem infoeach), parents that are themselves trashed (named from the same listing), and a bounded search of theremote_rootsubtree (DriveClient.find_folder_paths()). Whatever stays unresolved gets an honest marker rather than a bare?:(not under <remote_root>)when the whole subtree was searched,(not found within search limit)when the search was cut short,(unknown)for an entry with noparentUid.- Parameters:
ctx (
RepoContext) – the repo context (itsremote_rootbounds the search).
- Return type:
- Returns:
{parentUid: display text}for every distinctparentUid.
Added in version 3.4.0.