Skip to content

Fix --restrict-to-path with spaces and forward slashes on Windows (#82, #83) - #84

Merged
jessesaga merged 4 commits into
masterfrom
fix/issue-82-83-windows
Jun 11, 2026
Merged

Fix --restrict-to-path with spaces and forward slashes on Windows (#82, #83)#84
jessesaga merged 4 commits into
masterfrom
fix/issue-82-83-windows

Conversation

@jessesaga

Copy link
Copy Markdown
Contributor

Summary

Fixes two related Windows bugs with --restrict-to-path:

Approach

Built on @JosephTelford's Windows-developed-and-tested fixes (commits d010ef4, 6ac4fb7), plus two small, separately-scoped additions.

Commit Author What
d010ef4 Joseph Telford Spawn Java directly (no shell) in the npm launcher's main spawn — the #82 root cause
6ac4fb7 Joseph Telford Normalize -r separators to File/separator so forward-slash restrict paths match on Windows — the #83 root cause; keeps the existing startsWith matcher
74e5043 Also de-shell the npm findJava detection + guard on !error; quote the jar path and "$@" in mirthsync.sh/mirthsync.bat for non-npm users
4265248 Fix capture-pre-pull-local-files to compare against File/separator instead of a hardcoded "/", so Windows --delete-orphaned no longer captures (and risks deleting) unmanaged files like .git

On-disk format is unchanged

This deliberately does not touch where files are written. Separator normalization is applied to -r only (a pure filter — restrict-to-path never constructs a write path), -t is left as-is, and the existing startsWith matcher is kept. Pulled trees are byte-for-byte identical to 3.5.2 (verified by diffing full and restricted pulls).

Testing

  • Full lein test green locally: 41 tests, 351 assertions, 0 failures — including the live OIE 4.5.2 integration suite.
  • The base fixes (d010ef4, 6ac4fb7) are already green on the windows-latest CI job.

Closes #82
Closes #83

Joseph Telford and others added 4 commits June 11, 2026 17:52
…dows

The npm launcher spawned Java with shell:true on Windows, where Node
concatenates argv into an unquoted command string. Any argument
containing spaces was word-split before Java received it, breaking
command parsing.

Spawn Java with the argument array and no shell so each argument reaches
the JVM verbatim. findJava() already returns a concrete executable, so no
shell is needed for resolution.
Scoping a push or pull to a path (for example a single channel or group)
with --restrict-to-path selected nothing on Windows when the path was given
with forward slashes: the run completed without error, but no files were
written.

The value is matched against generated file paths with String/startsWith
(mirthsync.xml/serialize-node and mirthsync.actions/local-locs). The required
prefix was built from the raw restrict-to-path, while the file paths use the
platform File/separator, so a forward-slash path never matched the backslash
file paths on Windows and the filter excluded everything.

Normalize the restrict-to-path separators to File/separator when parsing the
option so the prefix matches regardless of which slash style was supplied.
Add tests covering the normalization and a forward-slash pull.
Complements the npm main-spawn fix already on this branch:

- pkg/npm/bin/mirthsync.js: also spawn the java-version detection
  without a shell, and guard the result on !error so a missing java on
  Windows is not misread as present (a shell launched for a missing
  command still writes to stderr, which the old check treated as
  "java found").
- pkg/mirthsync.sh / pkg/mirthsync.bat: quote the jar path and "$@" so
  a space-containing install path or argument survives in the non-npm
  launchers.
capture-pre-pull-local-files decides whether an API is rooted at the
target by stripping a trailing separator from its local-path and
comparing to the target. The strip used a hardcoded "/", so on Windows
the trailing File/separator (backslash) was not removed, the comparison
failed, and root-level APIs (resources, configuration-map, backup) fell
into the all-files-seq branch -- capturing every file under the target
root (including .git and other user-maintained files) as orphan-delete
candidates. With --delete-orphaned those unmanaged files could be
deleted.

Compare against File/separator instead. No-op on POSIX (separator is
already "/"); on Windows, root-level APIs now capture only their managed
file. Update the delete-orphaned test mock to return a
File/separator-terminated local-path (the hardcoded "/" mock would fail
on Windows once the production check uses File/separator).
@jessesaga
jessesaga merged commit 2106b3b into master Jun 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants