@poe-platform/safe-fs 0.1.755 → 0.1.757
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/safe-fs/contracts/descriptor.d.ts +2 -1
- package/dist/safe-fs/fs/descriptor.d.ts +1 -1
- package/dist/safe-fs/fs/descriptor.js +4 -4
- package/dist/safe-fs/fs/object-publication/index.js +2 -2
- package/dist/safe-fs/fs/scoped.js +1 -1
- package/dist/safe-fs/python/filesystem.js +2 -2
- package/package.json +1 -1
|
@@ -33,5 +33,6 @@ export interface FileDescriptor {
|
|
|
33
33
|
write(buffer: Uint8Array, position: number | null, options?: FsOptions): Promise<number>;
|
|
34
34
|
truncate(length: number, options?: FsOptions): Promise<void>;
|
|
35
35
|
sync(dataOnly: boolean, options?: FsOptions): Promise<void>;
|
|
36
|
-
close
|
|
36
|
+
/** Cancel cooperative close-time publication, while still releasing resources. */
|
|
37
|
+
close(options?: FsOptions): Promise<void>;
|
|
37
38
|
}
|
|
@@ -15,7 +15,7 @@ export interface DescriptorBackend<Resource> {
|
|
|
15
15
|
write(resource: Resource, buffer: Uint8Array, position: number | null, options: FsOptions): Promise<number>;
|
|
16
16
|
truncate(resource: Resource, length: number, options: FsOptions): Promise<void>;
|
|
17
17
|
sync(resource: Resource, dataOnly: boolean, options: FsOptions): Promise<void>;
|
|
18
|
-
close(resource: Resource): Promise<void>;
|
|
18
|
+
close(resource: Resource, options: FsOptions): Promise<void>;
|
|
19
19
|
}
|
|
20
20
|
export declare function forwardFileDescriptor(descriptor: FileDescriptor, operation: <Result>(syscall: string, options: FsOptions, action: () => Promise<Result>) => Promise<Result>, capabilities?: FileDescriptorCapabilities, snapshot?: (stat: FileStat) => FileStat): DescriptorBackend<FileDescriptor>;
|
|
21
21
|
export declare function openFileDescriptor<Resource>(path: string, options: OpenFileOptions, capabilities: FileDescriptorCapabilities, acquire: (options: DescriptorOpenOptions) => Promise<DescriptorBackend<Resource>>): Promise<FileDescriptor>;
|
|
@@ -38,7 +38,7 @@ export function forwardFileDescriptor(descriptor, operation, capabilities, snaps
|
|
|
38
38
|
write: (retained, buffer, position, options) => operation("write", options, () => retained.write(buffer, position, options)),
|
|
39
39
|
truncate: (retained, length, options) => operation("ftruncate", options, () => retained.truncate(length, options)),
|
|
40
40
|
sync: (retained, dataOnly, options) => operation(dataOnly ? "fdatasync" : "fsync", options, () => retained.sync(dataOnly, options)),
|
|
41
|
-
close: retained => operation("close", {}, () => retained.close()),
|
|
41
|
+
close: (retained, options) => operation("close", {}, () => retained.close(options)),
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
function integer(value, syscall, path) {
|
|
@@ -207,10 +207,10 @@ class ManagedFileDescriptor {
|
|
|
207
207
|
await backend.sync(backend.resource, dataOnly, forwarded);
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
|
-
close() {
|
|
210
|
+
close(options = {}) {
|
|
211
211
|
this.#closing ??= this.#pending.then(async () => {
|
|
212
212
|
try {
|
|
213
|
-
await this.#backend.close(this.#backend.resource);
|
|
213
|
+
await this.#backend.close(this.#backend.resource, options);
|
|
214
214
|
}
|
|
215
215
|
finally {
|
|
216
216
|
this.#backend = undefined;
|
|
@@ -272,7 +272,7 @@ export async function openFileDescriptor(path, options, capabilities, acquire) {
|
|
|
272
272
|
return descriptor;
|
|
273
273
|
}
|
|
274
274
|
catch (error) {
|
|
275
|
-
await finishCleanup(() => backend.close(backend.resource), true);
|
|
275
|
+
await finishCleanup(() => backend.close(backend.resource, {}), true);
|
|
276
276
|
signal?.throwIfAborted();
|
|
277
277
|
throw error;
|
|
278
278
|
}
|
|
@@ -394,11 +394,11 @@ export function withObjectFileDescriptors(filesystem, store, options = {}) {
|
|
|
394
394
|
await flush(forwarded);
|
|
395
395
|
},
|
|
396
396
|
sync: async (_state, _dataOnly, forwarded) => { await flush(forwarded); },
|
|
397
|
-
close: async () => {
|
|
397
|
+
close: async (_state, forwarded) => {
|
|
398
398
|
let failed = false;
|
|
399
399
|
try {
|
|
400
400
|
if (state.dirty || state.failure)
|
|
401
|
-
await flush(
|
|
401
|
+
await flush(forwarded);
|
|
402
402
|
}
|
|
403
403
|
catch (error) {
|
|
404
404
|
failed = true;
|
|
@@ -185,7 +185,7 @@ export function scopeFileSystem(filesystem, charge, signal, cleanupCharge = char
|
|
|
185
185
|
write: (buffer, position, forwarded = {}) => invoke(forwarded, scoped => descriptor.write(buffer, position, scoped), options.preserveDescriptorWriteReceipt === true),
|
|
186
186
|
truncate: (length, options = {}) => invoke(options, scoped => descriptor.truncate(length, scoped)),
|
|
187
187
|
sync: (dataOnly, options = {}) => invoke(options, scoped => descriptor.sync(dataOnly, scoped)),
|
|
188
|
-
close: () => closing ??= Promise.resolve().then(() => descriptor.close()),
|
|
188
|
+
close: (options = {}) => closing ??= Promise.resolve().then(() => descriptor.close(options)),
|
|
189
189
|
};
|
|
190
190
|
};
|
|
191
191
|
const wrapStream = (source, options) => {
|
|
@@ -72,7 +72,7 @@ export class PythonFileSystem {
|
|
|
72
72
|
const [id] = request.args;
|
|
73
73
|
const handle = this.#handle(id);
|
|
74
74
|
this.#handles.delete(id);
|
|
75
|
-
await handle.close();
|
|
75
|
+
await handle.close({ signal: this.#scope.signal });
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
const signal = this.#scope.signal;
|
|
@@ -230,7 +230,7 @@ export class PythonFileSystem {
|
|
|
230
230
|
await Promise.allSettled([...this.#pending]);
|
|
231
231
|
const handles = [...this.#handles.values()];
|
|
232
232
|
this.#handles.clear();
|
|
233
|
-
const results = await Promise.allSettled(handles.map(handle => handle.close()));
|
|
233
|
+
const results = await Promise.allSettled(handles.map(handle => handle.close({ signal: this.#scope.signal })));
|
|
234
234
|
this.#scope.dispose();
|
|
235
235
|
const failed = results.find(result => result.status === "rejected");
|
|
236
236
|
if (failed?.status === "rejected")
|