From 41d03f0a35a95daa7d54e7f29ab924776bedf6e4 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Thu, 15 Oct 2026 17:42:30 +0200 Subject: fix(cli): make the command-line client work on Windows Its suite had only run on Linux. On Windows, against a real hub and node and from the installed meshbay-cli.exe: - secrets.enc was written in text mode (os.open without O_BINARY): every 0x0A of the ciphertext became CR LF and the saved session "does not open with its key" on the next run. - isatty() is true for NUL, so a script run with `< NUL` or by the Task Scheduler was asked questions instead of told to pass --yes; output.terminal() checks for a real console. - Ctrl+C waited for the selector loop's next timer, up to half a minute in `chat --follow`; the loop now points the signal wakeup at its self-pipe, as the proactor does. - Right-click copy and paste raised: asyncio cannot start a process on the selector loop; the clipboard tool runs in a thread. - Tab completion of remote paths ran on the default (proactor) loop, which never opens a node, and wrote in the locale encoding; the PowerShell script now reads it as UTF-8. - `get -R` into a folder past MAX_PATH died with a traceback; get, put, the resume file and the interactive mode use the extended form at each disk call, as the node does. - `groups` showed a SQLite hub's naive UTC time as local time. The opt-in end-to-end suite now runs on Windows (16 tests: Chrome found under Program Files and started with the real environment, VLC as the player, Ctrl+C through a console of its own, PowerShell 5.1 completion of an accented name). Co-Authored-By: Claude Opus 5.5 --- packages/meshbay-cli/src/meshbay_cli/client/transfers.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'packages/meshbay-cli/src/meshbay_cli/client/transfers.py') diff --git a/packages/meshbay-cli/src/meshbay_cli/client/transfers.py b/packages/meshbay-cli/src/meshbay_cli/client/transfers.py index 2cbf4cd..177c78b 100644 --- a/packages/meshbay-cli/src/meshbay_cli/client/transfers.py +++ b/packages/meshbay-cli/src/meshbay_cli/client/transfers.py @@ -128,7 +128,8 @@ class Resume: sidecar = target.with_name(target.name + PART_SUFFIX + ".json") done = 0 try: - meta = json.loads(sidecar.read_text(encoding="utf-8")) + with open(long_path(sidecar), encoding="utf-8") as f: + meta = json.load(f) if meta.get("id") == entry["id"] and meta.get("size") == entry["size"]: # Every chunk but the last is whole, so the complete ones are # what the part's length says. @@ -198,8 +199,8 @@ def _prepare_part(resume: Resume, entry: dict, start: int) -> None: pass else: os.truncate(part, start * DOWNLOAD_CHUNK) - resume.sidecar.write_text(json.dumps({"id": entry["id"], "size": entry["size"]}), - encoding="utf-8") + with open(long_path(resume.sidecar), "w", encoding="utf-8") as f: + json.dump({"id": entry["id"], "size": entry["size"]}, f) def _publish(resume: Resume, target: Path, overwrite: bool) -> None: @@ -220,7 +221,7 @@ def _publish(resume: Resume, target: Path, overwrite: bool) -> None: raise TransferError(f"{target} already exists.") from None os.replace(part, dest) with contextlib.suppress(OSError): - resume.sidecar.unlink() + os.unlink(long_path(resume.sidecar)) if sys.platform == "win32": mark_of_the_web(target) -- cgit v1.2.3