Skip to main content

delete_file

Function delete_file 

Source
pub async fn delete_file(
    __arg0: State<AppState>,
    identity: Option<Extension<Identity>>,
    __arg2: Query<DeleteQuery>,
) -> Response
Expand description

DELETE /api/v1/fs/file — remove one named entry.

A real directory is refused unless recursive=true is given: the threat model is an agent’s mistake, not an attacker, so the guard is a single required flag rather than a confirmation flow. With it, the whole tree is walked and removed through remove_tree — the same traversal dry_run uses to preview it — and a tree holding an upload in flight is refused whole rather than partly removed.

Everything else the entry could be — a regular file, a symlink (to a file or to a directory), a FIFO, a socket, a device node — is removed. Unlike download, this handler never reads the entry’s contents, so download’s reason for gating on is_file() (a FIFO never reaches EOF) does not apply here; and refusing a non-regular entry would leave it permanently undeletable through this API, the same trap that decided the symlink question below in favour of acting on the named entry.

Accepted limitation: the paragraph above holds only for a link that itself resolves inside the root. A symlink pointing outside the root, or a dangling one, stays undeletable through this route — both are refused with Escapes before the named-entry logic below ever runs, because the jail’s verdict on the full path is final, and reaching either kind of link would mean overriding it. That is the property every other route in this feature rests on, so it is not relaxed here just to reach a broken link; an operator has to remove those directly.