Skip to content

FIX: rclone - directory listing broken by rclone log messages - #47

Open
miklos-szel wants to merge 2 commits into
doublecmd:masterfrom
miklos-szel:wfx_rclone_stderr
Open

FIX: rclone - directory listing broken by rclone log messages#47
miklos-szel wants to merge 2 commits into
doublecmd:masterfrom
miklos-szel:wfx_rclone_stderr

Conversation

@miklos-szel

Copy link
Copy Markdown
Contributor

Problem

Browsing any remote that makes rclone emit a log message fails - the panel shows an empty or unreadable directory. Easiest way to reproduce is an SFTP remote without known_hosts_file:

$ rclone lsjson hetenc:
2026/08/13 09:09:28 NOTICE: het: No host key validation is being performed. Set known_hosts_file to enable it. See: https://rclone.org/sftp/#host-key-validation
[
{"Path":".AppleDB", ...

Cause

That notice goes to stderr, but TRcloneCli.RunCommand ran the child process with poStderrToOutPut, so the log lines were prepended to the stdout of lsjson. The result is not valid JSON, GetJSON raises, ParseLsJson swallows the exception and returns an empty list, and FsFindFirstW reports an empty directory.

Fix

Capture stdout and stderr on separate pipes, draining both in a single loop so neither pipe buffer can fill up and block the child process. LastError now carries the actual rclone error message instead of a mix of both streams.

RunCommandWithProgress keeps poStderrToOutPut on purpose - that is where --progress writes.

Additionally the parsers are made tolerant of unexpected output, so a stray line can never silently blank a listing again:

  • ParseLsJson skips anything printed before the JSON array.
  • ParseListRemotes only accepts lines ending with a colon, which is the format listremotes prints.

Testing

Tested on macOS against an SFTP remote that triggers the notice: listing, entering directories, and listremotes at the root all work again.

rclone writes log messages to stderr, e.g. the SFTP backend notice

  NOTICE: het: No host key validation is being performed.
          Set known_hosts_file to enable it.

but RunCommand ran the child process with poStderrToOutPut, so those
lines were prepended to the stdout of "lsjson". The resulting text is
not valid JSON, GetJSON raised an exception, ParseLsJson swallowed it
and returned an empty list, and FsFindFirstW ended up reporting an
empty/unreadable directory.

Capture stdout and stderr on separate pipes instead, draining both in
one loop so neither pipe buffer can fill up and block the child. As a
side effect LastError now holds the actual rclone error message rather
than a mix of both streams.

RunCommandWithProgress keeps poStderrToOutPut on purpose, that is where
--progress writes its output.

Also make the parsers tolerant of unexpected output: ParseLsJson skips
anything printed before the JSON array, and ParseListRemotes only
accepts lines ending with a colon, which is the format listremotes
prints.
@miklos-szel miklos-szel reopened this Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant