@gamerdexapp/gamerdex-sync 0.3.0 → 0.3.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
@@ -7,6 +7,14 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.1] - 2026-10-18
11
+
12
+ ### Fixed
13
+
14
+ - `OneDriveProvider` no longer brings back a file that another device removed. OneDrive creates a
15
+ file when a write with `If-Match` finds none. The provider now removes that file again and reports
16
+ a version conflict.
17
+
10
18
  ## [0.3.0] - 2026-10-18
11
19
 
12
20
  ### Added
package/dist/index.d.mts CHANGED
@@ -498,6 +498,11 @@ declare class OneDriveProvider implements SyncProvider {
498
498
  version: string;
499
499
  }>;
500
500
  remove(path: string, expectedVersion: string): Promise<void>;
501
+ /**
502
+ * OneDrive creates the file when a write with `If-Match` finds none, which would undo the
503
+ * removal that another device made. The file that was just created is removed again.
504
+ */
505
+ private undoCreate;
501
506
  private itemUrl;
502
507
  private ifMatch;
503
508
  private info;
package/dist/index.d.ts CHANGED
@@ -498,6 +498,11 @@ declare class OneDriveProvider implements SyncProvider {
498
498
  version: string;
499
499
  }>;
500
500
  remove(path: string, expectedVersion: string): Promise<void>;
501
+ /**
502
+ * OneDrive creates the file when a write with `If-Match` finds none, which would undo the
503
+ * removal that another device made. The file that was just created is removed again.
504
+ */
505
+ private undoCreate;
501
506
  private itemUrl;
502
507
  private ifMatch;
503
508
  private info;
package/dist/index.js CHANGED
@@ -1310,8 +1310,11 @@ var OneDriveProvider = class {
1310
1310
  throw new VersionConflictError(path);
1311
1311
  }
1312
1312
  await this.assertOk(response);
1313
- if (expectedVersion !== null && response.status === 201) throw new VersionConflictError(path);
1314
1313
  const result = await response.json().catch(() => null);
1314
+ if (expectedVersion !== null && response.status === 201) {
1315
+ await this.undoCreate(path, result);
1316
+ throw new VersionConflictError(path);
1317
+ }
1315
1318
  if (!isRecord8(result) || typeof result.eTag !== "string") {
1316
1319
  throw this.invalid("The write returned no version.");
1317
1320
  }
@@ -1327,6 +1330,18 @@ var OneDriveProvider = class {
1327
1330
  if (response.status === 412) throw new VersionConflictError(path);
1328
1331
  await this.assertOk(response);
1329
1332
  }
1333
+ /**
1334
+ * OneDrive creates the file when a write with `If-Match` finds none, which would undo the
1335
+ * removal that another device made. The file that was just created is removed again.
1336
+ */
1337
+ async undoCreate(path, created) {
1338
+ if (!isRecord8(created) || typeof created.eTag !== "string") return;
1339
+ try {
1340
+ await this.remove(path, created.eTag);
1341
+ } catch (error) {
1342
+ if (!(error instanceof VersionConflictError)) throw error;
1343
+ }
1344
+ }
1330
1345
  itemUrl(path) {
1331
1346
  return `${APP_FOLDER}:/${encodePath2(path)}`;
1332
1347
  }