@narumitw/pi-sync-daemon 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @narumitw/pi-sync-daemon
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 06b470f: Fix Windows settings saves that fail with `EPERM` during atomic replacement by closing the previous settings handle before rename. Preserve source validation, rollback bytes, and POSIX concurrent-edit checks.
8
+
3
9
  ## 0.5.0
4
10
 
5
11
  ### Minor Changes
@@ -241,12 +241,20 @@ async function replaceLocalConfigDocumentUnlocked(document, value, signal) {
241
241
  if (previous.dev !== document.identity.dev || previous.ino !== document.identity.ino) {
242
242
  throw settingsChangedError();
243
243
  }
244
+ let previousBytesRead;
245
+ const readPreviousBytes = () => (previousBytesRead ??= previousHandle.readFile());
246
+ if (process.platform === "win32") {
247
+ // Windows cannot replace an open destination. Pin rollback bytes and close our reader;
248
+ // the publication guard still checks the live path. POSIX keeps the reader to detect
249
+ // writes through the retired inode after replacement.
250
+ if (!(await readPreviousBytes()).equals(document.bytes))
251
+ throw settingsChangedError();
252
+ await previousHandle.close();
253
+ }
244
254
  await writePrivateConfigBytes(recoveryPath, document.bytes, "wx");
245
255
  await syncParentDirectory(canonicalPath);
246
256
  await withPrivateConfigTemporary(canonicalPath, nextBytes, async (temporaryPath, installed) => {
247
257
  let published = false;
248
- let previousBytesRead;
249
- const readPreviousBytes = () => (previousBytesRead ??= previousHandle.readFile());
250
258
  try {
251
259
  signal?.throwIfAborted();
252
260
  await publishConfigFile(temporaryPath, canonicalPath, document, signal);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-sync-daemon",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "A local synchronization daemon with a versioned client API.",
5
5
  "type": "module",
6
6
  "license": "MIT",