zen-fs-config 0.9.7 → 0.9.8
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/dist/index.js +12 -4
- package/dist/index.mjs +12 -4
- package/dist/zen-fs-config.js +12 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1879,7 +1879,7 @@ function toBytes(raw) {
|
|
|
1879
1879
|
if (typeof raw === "string") return new TextEncoder().encode(raw);
|
|
1880
1880
|
return new Uint8Array(raw);
|
|
1881
1881
|
}
|
|
1882
|
-
async function writeFileOverwrite(fs, path, data) {
|
|
1882
|
+
async function writeFileOverwrite(fs, path, data, options = {}) {
|
|
1883
1883
|
const bytes = toBytes(data);
|
|
1884
1884
|
try {
|
|
1885
1885
|
await fs.writeFile(path, bytes);
|
|
@@ -1891,7 +1891,15 @@ async function writeFileOverwrite(fs, path, data) {
|
|
|
1891
1891
|
await fs.unlink(path);
|
|
1892
1892
|
} catch {
|
|
1893
1893
|
}
|
|
1894
|
-
|
|
1894
|
+
try {
|
|
1895
|
+
await fs.writeFile(path, bytes);
|
|
1896
|
+
} catch (err) {
|
|
1897
|
+
if (isAlreadyExistsError(err) && options.ignorePersistentEexist) {
|
|
1898
|
+
log3.warn(`[zen-fs-config] writeFileOverwrite: \u540C\u540D\u6587\u4EF6\u65E0\u6CD5\u8986\u76D6\uFF0C\u6309\u5DF2\u5B58\u5728\u5904\u7406 ${path}`);
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
throw err;
|
|
1902
|
+
}
|
|
1895
1903
|
}
|
|
1896
1904
|
function isAlreadyExistsError(err) {
|
|
1897
1905
|
const e = err;
|
|
@@ -2207,14 +2215,14 @@ var TombstoneStore = class {
|
|
|
2207
2215
|
const bytes = new TextEncoder().encode(serializeTombstone(tombstone));
|
|
2208
2216
|
const p = this.pathFor(tombstone.path);
|
|
2209
2217
|
await ensureParentDir2(this.fs, p);
|
|
2210
|
-
await writeFileOverwrite(this.fs, p, bytes);
|
|
2218
|
+
await writeFileOverwrite(this.fs, p, bytes, { ignorePersistentEexist: true });
|
|
2211
2219
|
}
|
|
2212
2220
|
/** Persist an updated tombstone (confirmations) when it still exists. */
|
|
2213
2221
|
async save(tombstone) {
|
|
2214
2222
|
const bytes = new TextEncoder().encode(serializeTombstone(tombstone));
|
|
2215
2223
|
const p = this.pathFor(tombstone.path);
|
|
2216
2224
|
if (!await existsSafe(this.fs, p)) return;
|
|
2217
|
-
await writeFileOverwrite(this.fs, p, bytes);
|
|
2225
|
+
await writeFileOverwrite(this.fs, p, bytes, { ignorePersistentEexist: true });
|
|
2218
2226
|
}
|
|
2219
2227
|
/** Delete a tombstone. */
|
|
2220
2228
|
async remove(tombstone) {
|
package/dist/index.mjs
CHANGED
|
@@ -1091,7 +1091,7 @@ function toBytes(raw) {
|
|
|
1091
1091
|
if (typeof raw === "string") return new TextEncoder().encode(raw);
|
|
1092
1092
|
return new Uint8Array(raw);
|
|
1093
1093
|
}
|
|
1094
|
-
async function writeFileOverwrite(fs, path, data) {
|
|
1094
|
+
async function writeFileOverwrite(fs, path, data, options = {}) {
|
|
1095
1095
|
const bytes = toBytes(data);
|
|
1096
1096
|
try {
|
|
1097
1097
|
await fs.writeFile(path, bytes);
|
|
@@ -1103,7 +1103,15 @@ async function writeFileOverwrite(fs, path, data) {
|
|
|
1103
1103
|
await fs.unlink(path);
|
|
1104
1104
|
} catch {
|
|
1105
1105
|
}
|
|
1106
|
-
|
|
1106
|
+
try {
|
|
1107
|
+
await fs.writeFile(path, bytes);
|
|
1108
|
+
} catch (err) {
|
|
1109
|
+
if (isAlreadyExistsError(err) && options.ignorePersistentEexist) {
|
|
1110
|
+
log3.warn(`[zen-fs-config] writeFileOverwrite: \u540C\u540D\u6587\u4EF6\u65E0\u6CD5\u8986\u76D6\uFF0C\u6309\u5DF2\u5B58\u5728\u5904\u7406 ${path}`);
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
throw err;
|
|
1114
|
+
}
|
|
1107
1115
|
}
|
|
1108
1116
|
function isAlreadyExistsError(err) {
|
|
1109
1117
|
const e = err;
|
|
@@ -1419,14 +1427,14 @@ var TombstoneStore = class {
|
|
|
1419
1427
|
const bytes = new TextEncoder().encode(serializeTombstone(tombstone));
|
|
1420
1428
|
const p = this.pathFor(tombstone.path);
|
|
1421
1429
|
await ensureParentDir2(this.fs, p);
|
|
1422
|
-
await writeFileOverwrite(this.fs, p, bytes);
|
|
1430
|
+
await writeFileOverwrite(this.fs, p, bytes, { ignorePersistentEexist: true });
|
|
1423
1431
|
}
|
|
1424
1432
|
/** Persist an updated tombstone (confirmations) when it still exists. */
|
|
1425
1433
|
async save(tombstone) {
|
|
1426
1434
|
const bytes = new TextEncoder().encode(serializeTombstone(tombstone));
|
|
1427
1435
|
const p = this.pathFor(tombstone.path);
|
|
1428
1436
|
if (!await existsSafe(this.fs, p)) return;
|
|
1429
|
-
await writeFileOverwrite(this.fs, p, bytes);
|
|
1437
|
+
await writeFileOverwrite(this.fs, p, bytes, { ignorePersistentEexist: true });
|
|
1430
1438
|
}
|
|
1431
1439
|
/** Delete a tombstone. */
|
|
1432
1440
|
async remove(tombstone) {
|
package/dist/zen-fs-config.js
CHANGED
|
@@ -27845,7 +27845,7 @@ var ZenFSConfig = (() => {
|
|
|
27845
27845
|
if (typeof raw === "string") return new TextEncoder().encode(raw);
|
|
27846
27846
|
return new Uint8Array(raw);
|
|
27847
27847
|
}
|
|
27848
|
-
async function writeFileOverwrite(fs, path, data) {
|
|
27848
|
+
async function writeFileOverwrite(fs, path, data, options = {}) {
|
|
27849
27849
|
const bytes = toBytes(data);
|
|
27850
27850
|
try {
|
|
27851
27851
|
await fs.writeFile(path, bytes);
|
|
@@ -27857,7 +27857,15 @@ var ZenFSConfig = (() => {
|
|
|
27857
27857
|
await fs.unlink(path);
|
|
27858
27858
|
} catch {
|
|
27859
27859
|
}
|
|
27860
|
-
|
|
27860
|
+
try {
|
|
27861
|
+
await fs.writeFile(path, bytes);
|
|
27862
|
+
} catch (err2) {
|
|
27863
|
+
if (isAlreadyExistsError(err2) && options.ignorePersistentEexist) {
|
|
27864
|
+
log7.warn(`[zen-fs-config] writeFileOverwrite: \u540C\u540D\u6587\u4EF6\u65E0\u6CD5\u8986\u76D6\uFF0C\u6309\u5DF2\u5B58\u5728\u5904\u7406 ${path}`);
|
|
27865
|
+
return;
|
|
27866
|
+
}
|
|
27867
|
+
throw err2;
|
|
27868
|
+
}
|
|
27861
27869
|
}
|
|
27862
27870
|
function isAlreadyExistsError(err2) {
|
|
27863
27871
|
const e = err2;
|
|
@@ -28171,14 +28179,14 @@ var ZenFSConfig = (() => {
|
|
|
28171
28179
|
const bytes = new TextEncoder().encode(serializeTombstone(tombstone));
|
|
28172
28180
|
const p = this.pathFor(tombstone.path);
|
|
28173
28181
|
await ensureParentDir2(this.fs, p);
|
|
28174
|
-
await writeFileOverwrite(this.fs, p, bytes);
|
|
28182
|
+
await writeFileOverwrite(this.fs, p, bytes, { ignorePersistentEexist: true });
|
|
28175
28183
|
}
|
|
28176
28184
|
/** Persist an updated tombstone (confirmations) when it still exists. */
|
|
28177
28185
|
async save(tombstone) {
|
|
28178
28186
|
const bytes = new TextEncoder().encode(serializeTombstone(tombstone));
|
|
28179
28187
|
const p = this.pathFor(tombstone.path);
|
|
28180
28188
|
if (!await existsSafe(this.fs, p)) return;
|
|
28181
|
-
await writeFileOverwrite(this.fs, p, bytes);
|
|
28189
|
+
await writeFileOverwrite(this.fs, p, bytes, { ignorePersistentEexist: true });
|
|
28182
28190
|
}
|
|
28183
28191
|
/** Delete a tombstone. */
|
|
28184
28192
|
async remove(tombstone) {
|