Skip to content

[BUG] [File Manager] Delete fails silently on Windows hosts — rm -f not supported by PowerShell #758

Description

@tbo-cosp

Title

[File Manager] Delete fails silently on Windows hosts — rm -f not supported by PowerShell

Platform

App - Windows

Server Installation Method

Proxmox (Community Scripts)

Version

2.3.1

Troubleshooting

The Problem

Description

When using the Termix file manager to delete a file on a Windows Server host (OpenSSH), clicking "Delete" and confirming shows no error message — the operation silently fails and the file remains.

Investigation of file-manager.js reveals that the delete operation executes the following shell command over SSH:

rm -f '<path>' && echo "SUCCESS"

This command is Linux-specific. On Windows, PowerShell's rm alias maps to Remove-Item but does not support the -f flag in the same way, and single-quoted Windows paths with backslashes are not handled correctly in non-interactive SSH sessions. The command fails silently — no Permission denied is returned, so Termix never logs an error.

Steps to reproduce

  1. Add a Windows Server host in Termix (OpenSSH enabled)
  2. Open the File Manager on that host
  3. Right-click a file → Delete → Confirm
  4. Observe: popup "Failed to delete" appears, file is not deleted, no error in Termix logs

Expected behavior

File is deleted successfully, or an explicit error message is shown explaining the incompatibility.

Observed behavior

Silent failure. Termix logs show file_delete event but no file_delete_success or error event follows. The rm -f command is sent but returns no output the backend can interpret as success.

Root cause

In backend/ssh/file-manager.js, the delete command is hardcoded as:

const deleteCommand = isDirectory
  ? `rm -rf '${escapedPath}'`
  : `rm -f '${escapedPath}'`;

These are POSIX commands. On Windows hosts, a PowerShell-compatible equivalent should be used, e.g.:

Remove-Item -Force -Path '<path>' or cmd /c del /f "<path>"

Suggested fix

Detect the remote OS before building the delete command (e.g. using a previous uname / ver probe, or a flag stored on the host record), then branch the command accordingly:

  • Linux/macOS → current rm -f behaviour (no change)
  • Windows → Remove-Item -Force -LiteralPath '<path>'

Environment

  • Termix version: latest self-hosted (LXC container, Debian)
  • Remote host OS: Windows Server (OpenSSH for Windows)
  • SSH subsystem: sftp-server.exe
  • Browser: web interface

Acceptance criteria

  • Deleting a file on a Windows host via the file manager succeeds without error
  • Deleting a file on a Linux host is unaffected
  • A meaningful error message is shown if the delete fails for any reason
  • The fix handles both files and directories

How to Reproduce

Steps to reproduce

  1. Add a Windows Server host in Termix (OpenSSH enabled)
  2. Open the File Manager on that host
  3. Right-click a file → Delete → Confirm
  4. Observe: popup "Failed to delete" appears, file is not deleted, no error in Termix logs

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions