zen-fs-config 0.7.12 → 0.7.13
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 +27 -11
- package/dist/index.mjs +27 -11
- package/dist/zen-fs-config.js +27 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -855,6 +855,13 @@ function makeEperm(userPath) {
|
|
|
855
855
|
err.code = "EPERM";
|
|
856
856
|
return err;
|
|
857
857
|
}
|
|
858
|
+
function makeEconfirm(userPath) {
|
|
859
|
+
const err = new Error(
|
|
860
|
+
`ECONFIRM: '${userPath}' changes sync metadata \u2014 retry with { confirm: true } after warning the user`
|
|
861
|
+
);
|
|
862
|
+
err.code = "ECONFIRM";
|
|
863
|
+
return err;
|
|
864
|
+
}
|
|
858
865
|
function createChrootFS(inner, root, options = {}) {
|
|
859
866
|
const normalizedRoot = root.replace(/\\/g, "/").replace(/\/+$/, "") || "/";
|
|
860
867
|
const hiddenPrefixes = (options.hiddenPrefixes ?? []).map(
|
|
@@ -863,6 +870,9 @@ function createChrootFS(inner, root, options = {}) {
|
|
|
863
870
|
const readOnlyPrefixes = (options.readOnlyPrefixes ?? []).map(
|
|
864
871
|
(p) => p.startsWith("/") ? p.replace(/\/+$/, "") : `/${p}`.replace(/\/+$/, "")
|
|
865
872
|
);
|
|
873
|
+
const confirmPrefixes = (options.confirmPrefixes ?? []).map(
|
|
874
|
+
(p) => p.startsWith("/") ? p.replace(/\/+$/, "") : `/${p}`.replace(/\/+$/, "")
|
|
875
|
+
);
|
|
866
876
|
function rp(path) {
|
|
867
877
|
return resolveChroot(normalizedRoot, path);
|
|
868
878
|
}
|
|
@@ -881,9 +891,15 @@ function createChrootFS(inner, root, options = {}) {
|
|
|
881
891
|
(prefix) => absolutePath === prefix || absolutePath.startsWith(`${prefix}/`)
|
|
882
892
|
);
|
|
883
893
|
}
|
|
884
|
-
function
|
|
894
|
+
function needsConfirm(absolutePath) {
|
|
895
|
+
return confirmPrefixes.some(
|
|
896
|
+
(prefix) => absolutePath === prefix || absolutePath.startsWith(`${prefix}/`)
|
|
897
|
+
);
|
|
898
|
+
}
|
|
899
|
+
function writable(path, writeOptions) {
|
|
885
900
|
const absolute = visible(path);
|
|
886
901
|
if (isReadOnly(absolute)) throw makeEperm(path);
|
|
902
|
+
if (needsConfirm(absolute) && writeOptions?.confirm !== true) throw makeEconfirm(path);
|
|
887
903
|
return absolute;
|
|
888
904
|
}
|
|
889
905
|
const promises = {
|
|
@@ -891,7 +907,7 @@ function createChrootFS(inner, root, options = {}) {
|
|
|
891
907
|
return inner.readFile(visible(path), encoding);
|
|
892
908
|
},
|
|
893
909
|
async writeFile(path, data, writeOptions) {
|
|
894
|
-
const target = writable(path);
|
|
910
|
+
const target = writable(path, writeOptions);
|
|
895
911
|
await ensureParentDir(target);
|
|
896
912
|
await inner.writeFile(target, data, writeOptions);
|
|
897
913
|
if (options.onWrite) await options.onWrite(path, data);
|
|
@@ -918,21 +934,21 @@ function createChrootFS(inner, root, options = {}) {
|
|
|
918
934
|
if (!exists) throw makeEnoent(path);
|
|
919
935
|
},
|
|
920
936
|
async mkdir(path, mkdirOptions) {
|
|
921
|
-
return inner.mkdir(writable(path), mkdirOptions);
|
|
937
|
+
return inner.mkdir(writable(path, mkdirOptions), mkdirOptions);
|
|
922
938
|
},
|
|
923
|
-
async unlink(path) {
|
|
924
|
-
const target = writable(path);
|
|
939
|
+
async unlink(path, unlinkOptions) {
|
|
940
|
+
const target = writable(path, unlinkOptions);
|
|
925
941
|
if (options.onUnlink) return options.onUnlink(target);
|
|
926
942
|
return inner.unlink(target);
|
|
927
943
|
},
|
|
928
|
-
async rmdir(path) {
|
|
929
|
-
const target = writable(path);
|
|
944
|
+
async rmdir(path, rmdirOptions) {
|
|
945
|
+
const target = writable(path, rmdirOptions);
|
|
930
946
|
const hook = options.onRmdir ?? options.onUnlink;
|
|
931
947
|
if (hook) return hook(target);
|
|
932
948
|
return inner.rmdir?.(target);
|
|
933
949
|
},
|
|
934
|
-
async rename(oldPath, newPath) {
|
|
935
|
-
return inner.rename?.(writable(oldPath), writable(newPath));
|
|
950
|
+
async rename(oldPath, newPath, renameOptions) {
|
|
951
|
+
return inner.rename?.(writable(oldPath, renameOptions), writable(newPath, renameOptions));
|
|
936
952
|
},
|
|
937
953
|
async exists(path) {
|
|
938
954
|
if (isHidden(rp(path))) return false;
|
|
@@ -5397,9 +5413,9 @@ var AppDataGroupImpl = class {
|
|
|
5397
5413
|
LEGACY_TOMBSTONES_DIR,
|
|
5398
5414
|
VERSIONS_DIR,
|
|
5399
5415
|
CONFLICTS_DIR,
|
|
5400
|
-
LEGACY_CONFLICTS_DIR
|
|
5401
|
-
GROUP_DESCRIPTOR_FILE3
|
|
5416
|
+
LEGACY_CONFLICTS_DIR
|
|
5402
5417
|
],
|
|
5418
|
+
confirmPrefixes: [GROUP_DESCRIPTOR_FILE3],
|
|
5403
5419
|
onWrite: async (path, data) => {
|
|
5404
5420
|
if (path.startsWith(`${META_DIR}/`) || path === META_DIR) return;
|
|
5405
5421
|
await this.clearTombstonesForWrite(path);
|
package/dist/index.mjs
CHANGED
|
@@ -110,6 +110,13 @@ function makeEperm(userPath) {
|
|
|
110
110
|
err.code = "EPERM";
|
|
111
111
|
return err;
|
|
112
112
|
}
|
|
113
|
+
function makeEconfirm(userPath) {
|
|
114
|
+
const err = new Error(
|
|
115
|
+
`ECONFIRM: '${userPath}' changes sync metadata \u2014 retry with { confirm: true } after warning the user`
|
|
116
|
+
);
|
|
117
|
+
err.code = "ECONFIRM";
|
|
118
|
+
return err;
|
|
119
|
+
}
|
|
113
120
|
function createChrootFS(inner, root, options = {}) {
|
|
114
121
|
const normalizedRoot = root.replace(/\\/g, "/").replace(/\/+$/, "") || "/";
|
|
115
122
|
const hiddenPrefixes = (options.hiddenPrefixes ?? []).map(
|
|
@@ -118,6 +125,9 @@ function createChrootFS(inner, root, options = {}) {
|
|
|
118
125
|
const readOnlyPrefixes = (options.readOnlyPrefixes ?? []).map(
|
|
119
126
|
(p) => p.startsWith("/") ? p.replace(/\/+$/, "") : `/${p}`.replace(/\/+$/, "")
|
|
120
127
|
);
|
|
128
|
+
const confirmPrefixes = (options.confirmPrefixes ?? []).map(
|
|
129
|
+
(p) => p.startsWith("/") ? p.replace(/\/+$/, "") : `/${p}`.replace(/\/+$/, "")
|
|
130
|
+
);
|
|
121
131
|
function rp(path) {
|
|
122
132
|
return resolveChroot(normalizedRoot, path);
|
|
123
133
|
}
|
|
@@ -136,9 +146,15 @@ function createChrootFS(inner, root, options = {}) {
|
|
|
136
146
|
(prefix) => absolutePath === prefix || absolutePath.startsWith(`${prefix}/`)
|
|
137
147
|
);
|
|
138
148
|
}
|
|
139
|
-
function
|
|
149
|
+
function needsConfirm(absolutePath) {
|
|
150
|
+
return confirmPrefixes.some(
|
|
151
|
+
(prefix) => absolutePath === prefix || absolutePath.startsWith(`${prefix}/`)
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
function writable(path, writeOptions) {
|
|
140
155
|
const absolute = visible(path);
|
|
141
156
|
if (isReadOnly(absolute)) throw makeEperm(path);
|
|
157
|
+
if (needsConfirm(absolute) && writeOptions?.confirm !== true) throw makeEconfirm(path);
|
|
142
158
|
return absolute;
|
|
143
159
|
}
|
|
144
160
|
const promises = {
|
|
@@ -146,7 +162,7 @@ function createChrootFS(inner, root, options = {}) {
|
|
|
146
162
|
return inner.readFile(visible(path), encoding);
|
|
147
163
|
},
|
|
148
164
|
async writeFile(path, data, writeOptions) {
|
|
149
|
-
const target = writable(path);
|
|
165
|
+
const target = writable(path, writeOptions);
|
|
150
166
|
await ensureParentDir(target);
|
|
151
167
|
await inner.writeFile(target, data, writeOptions);
|
|
152
168
|
if (options.onWrite) await options.onWrite(path, data);
|
|
@@ -173,21 +189,21 @@ function createChrootFS(inner, root, options = {}) {
|
|
|
173
189
|
if (!exists) throw makeEnoent(path);
|
|
174
190
|
},
|
|
175
191
|
async mkdir(path, mkdirOptions) {
|
|
176
|
-
return inner.mkdir(writable(path), mkdirOptions);
|
|
192
|
+
return inner.mkdir(writable(path, mkdirOptions), mkdirOptions);
|
|
177
193
|
},
|
|
178
|
-
async unlink(path) {
|
|
179
|
-
const target = writable(path);
|
|
194
|
+
async unlink(path, unlinkOptions) {
|
|
195
|
+
const target = writable(path, unlinkOptions);
|
|
180
196
|
if (options.onUnlink) return options.onUnlink(target);
|
|
181
197
|
return inner.unlink(target);
|
|
182
198
|
},
|
|
183
|
-
async rmdir(path) {
|
|
184
|
-
const target = writable(path);
|
|
199
|
+
async rmdir(path, rmdirOptions) {
|
|
200
|
+
const target = writable(path, rmdirOptions);
|
|
185
201
|
const hook = options.onRmdir ?? options.onUnlink;
|
|
186
202
|
if (hook) return hook(target);
|
|
187
203
|
return inner.rmdir?.(target);
|
|
188
204
|
},
|
|
189
|
-
async rename(oldPath, newPath) {
|
|
190
|
-
return inner.rename?.(writable(oldPath), writable(newPath));
|
|
205
|
+
async rename(oldPath, newPath, renameOptions) {
|
|
206
|
+
return inner.rename?.(writable(oldPath, renameOptions), writable(newPath, renameOptions));
|
|
191
207
|
},
|
|
192
208
|
async exists(path) {
|
|
193
209
|
if (isHidden(rp(path))) return false;
|
|
@@ -4648,9 +4664,9 @@ var AppDataGroupImpl = class {
|
|
|
4648
4664
|
LEGACY_TOMBSTONES_DIR,
|
|
4649
4665
|
VERSIONS_DIR,
|
|
4650
4666
|
CONFLICTS_DIR,
|
|
4651
|
-
LEGACY_CONFLICTS_DIR
|
|
4652
|
-
GROUP_DESCRIPTOR_FILE3
|
|
4667
|
+
LEGACY_CONFLICTS_DIR
|
|
4653
4668
|
],
|
|
4669
|
+
confirmPrefixes: [GROUP_DESCRIPTOR_FILE3],
|
|
4654
4670
|
onWrite: async (path, data) => {
|
|
4655
4671
|
if (path.startsWith(`${META_DIR}/`) || path === META_DIR) return;
|
|
4656
4672
|
await this.clearTombstonesForWrite(path);
|
package/dist/zen-fs-config.js
CHANGED
|
@@ -26829,6 +26829,13 @@ var ZenFSConfig = (() => {
|
|
|
26829
26829
|
err2.code = "EPERM";
|
|
26830
26830
|
return err2;
|
|
26831
26831
|
}
|
|
26832
|
+
function makeEconfirm(userPath) {
|
|
26833
|
+
const err2 = new Error(
|
|
26834
|
+
`ECONFIRM: '${userPath}' changes sync metadata \u2014 retry with { confirm: true } after warning the user`
|
|
26835
|
+
);
|
|
26836
|
+
err2.code = "ECONFIRM";
|
|
26837
|
+
return err2;
|
|
26838
|
+
}
|
|
26832
26839
|
function createChrootFS(inner, root, options = {}) {
|
|
26833
26840
|
const normalizedRoot = root.replace(/\\/g, "/").replace(/\/+$/, "") || "/";
|
|
26834
26841
|
const hiddenPrefixes = (options.hiddenPrefixes ?? []).map(
|
|
@@ -26837,6 +26844,9 @@ var ZenFSConfig = (() => {
|
|
|
26837
26844
|
const readOnlyPrefixes = (options.readOnlyPrefixes ?? []).map(
|
|
26838
26845
|
(p) => p.startsWith("/") ? p.replace(/\/+$/, "") : `/${p}`.replace(/\/+$/, "")
|
|
26839
26846
|
);
|
|
26847
|
+
const confirmPrefixes = (options.confirmPrefixes ?? []).map(
|
|
26848
|
+
(p) => p.startsWith("/") ? p.replace(/\/+$/, "") : `/${p}`.replace(/\/+$/, "")
|
|
26849
|
+
);
|
|
26840
26850
|
function rp(path) {
|
|
26841
26851
|
return resolveChroot(normalizedRoot, path);
|
|
26842
26852
|
}
|
|
@@ -26855,9 +26865,15 @@ var ZenFSConfig = (() => {
|
|
|
26855
26865
|
(prefix) => absolutePath === prefix || absolutePath.startsWith(`${prefix}/`)
|
|
26856
26866
|
);
|
|
26857
26867
|
}
|
|
26858
|
-
function
|
|
26868
|
+
function needsConfirm(absolutePath) {
|
|
26869
|
+
return confirmPrefixes.some(
|
|
26870
|
+
(prefix) => absolutePath === prefix || absolutePath.startsWith(`${prefix}/`)
|
|
26871
|
+
);
|
|
26872
|
+
}
|
|
26873
|
+
function writable(path, writeOptions) {
|
|
26859
26874
|
const absolute = visible(path);
|
|
26860
26875
|
if (isReadOnly(absolute)) throw makeEperm(path);
|
|
26876
|
+
if (needsConfirm(absolute) && writeOptions?.confirm !== true) throw makeEconfirm(path);
|
|
26861
26877
|
return absolute;
|
|
26862
26878
|
}
|
|
26863
26879
|
const promises = {
|
|
@@ -26865,7 +26881,7 @@ var ZenFSConfig = (() => {
|
|
|
26865
26881
|
return inner.readFile(visible(path), encoding);
|
|
26866
26882
|
},
|
|
26867
26883
|
async writeFile(path, data, writeOptions) {
|
|
26868
|
-
const target = writable(path);
|
|
26884
|
+
const target = writable(path, writeOptions);
|
|
26869
26885
|
await ensureParentDir(target);
|
|
26870
26886
|
await inner.writeFile(target, data, writeOptions);
|
|
26871
26887
|
if (options.onWrite) await options.onWrite(path, data);
|
|
@@ -26892,21 +26908,21 @@ var ZenFSConfig = (() => {
|
|
|
26892
26908
|
if (!exists3) throw makeEnoent(path);
|
|
26893
26909
|
},
|
|
26894
26910
|
async mkdir(path, mkdirOptions) {
|
|
26895
|
-
return inner.mkdir(writable(path), mkdirOptions);
|
|
26911
|
+
return inner.mkdir(writable(path, mkdirOptions), mkdirOptions);
|
|
26896
26912
|
},
|
|
26897
|
-
async unlink(path) {
|
|
26898
|
-
const target = writable(path);
|
|
26913
|
+
async unlink(path, unlinkOptions) {
|
|
26914
|
+
const target = writable(path, unlinkOptions);
|
|
26899
26915
|
if (options.onUnlink) return options.onUnlink(target);
|
|
26900
26916
|
return inner.unlink(target);
|
|
26901
26917
|
},
|
|
26902
|
-
async rmdir(path) {
|
|
26903
|
-
const target = writable(path);
|
|
26918
|
+
async rmdir(path, rmdirOptions) {
|
|
26919
|
+
const target = writable(path, rmdirOptions);
|
|
26904
26920
|
const hook = options.onRmdir ?? options.onUnlink;
|
|
26905
26921
|
if (hook) return hook(target);
|
|
26906
26922
|
return inner.rmdir?.(target);
|
|
26907
26923
|
},
|
|
26908
|
-
async rename(oldPath, newPath) {
|
|
26909
|
-
return inner.rename?.(writable(oldPath), writable(newPath));
|
|
26924
|
+
async rename(oldPath, newPath, renameOptions) {
|
|
26925
|
+
return inner.rename?.(writable(oldPath, renameOptions), writable(newPath, renameOptions));
|
|
26910
26926
|
},
|
|
26911
26927
|
async exists(path) {
|
|
26912
26928
|
if (isHidden(rp(path))) return false;
|
|
@@ -31354,9 +31370,9 @@ var ZenFSConfig = (() => {
|
|
|
31354
31370
|
LEGACY_TOMBSTONES_DIR,
|
|
31355
31371
|
VERSIONS_DIR,
|
|
31356
31372
|
CONFLICTS_DIR,
|
|
31357
|
-
LEGACY_CONFLICTS_DIR
|
|
31358
|
-
GROUP_DESCRIPTOR_FILE3
|
|
31373
|
+
LEGACY_CONFLICTS_DIR
|
|
31359
31374
|
],
|
|
31375
|
+
confirmPrefixes: [GROUP_DESCRIPTOR_FILE3],
|
|
31360
31376
|
onWrite: async (path, data) => {
|
|
31361
31377
|
if (path.startsWith(`${META_DIR}/`) || path === META_DIR) return;
|
|
31362
31378
|
await this.clearTombstonesForWrite(path);
|