@zenfs/core 1.2.9 → 1.3.0
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/backends/fetch.js +1 -1
- package/dist/backends/memory.d.ts +1 -2
- package/dist/backends/overlay.js +2 -3
- package/dist/backends/port/fs.d.ts +2 -15
- package/dist/backends/store/fs.d.ts +17 -28
- package/dist/backends/store/fs.js +169 -191
- package/dist/backends/store/simple.d.ts +20 -21
- package/dist/backends/store/simple.js +24 -24
- package/dist/backends/store/store.d.ts +22 -23
- package/dist/backends/store/store.js +6 -6
- package/dist/config.d.ts +8 -0
- package/dist/config.js +2 -1
- package/dist/devices.d.ts +2 -3
- package/dist/emulation/cache.d.ts +40 -31
- package/dist/emulation/cache.js +62 -53
- package/dist/emulation/index.d.ts +1 -1
- package/dist/emulation/index.js +1 -1
- package/dist/emulation/promises.js +18 -17
- package/dist/emulation/shared.d.ts +6 -0
- package/dist/emulation/shared.js +13 -1
- package/dist/emulation/sync.d.ts +1 -1
- package/dist/emulation/sync.js +16 -15
- package/dist/file.d.ts +3 -15
- package/dist/file.js +7 -19
- package/dist/inode.d.ts +4 -13
- package/dist/inode.js +22 -29
- package/dist/mixins/async.d.ts +15 -10
- package/dist/mixins/async.js +3 -1
- package/dist/stats.js +30 -5
- package/dist/utils.d.ts +5 -7
- package/dist/utils.js +11 -20
- package/package.json +1 -1
- package/src/backends/fetch.ts +1 -1
- package/src/backends/memory.ts +1 -2
- package/src/backends/overlay.ts +2 -2
- package/src/backends/store/fs.ts +187 -220
- package/src/backends/store/simple.ts +36 -37
- package/src/backends/store/store.ts +25 -26
- package/src/config.ts +11 -1
- package/src/devices.ts +2 -3
- package/src/emulation/cache.ts +68 -60
- package/src/emulation/index.ts +1 -1
- package/src/emulation/promises.ts +20 -19
- package/src/emulation/shared.ts +13 -1
- package/src/emulation/sync.ts +16 -15
- package/src/file.ts +9 -21
- package/src/inode.ts +10 -31
- package/src/mixins/async.ts +27 -24
- package/src/stats.ts +47 -5
- package/src/utils.ts +11 -23
- package/tests/fs/dir.test.ts +21 -31
- package/tests/fs/directory.test.ts +6 -4
- package/tests/fs/links.test.ts +9 -2
- package/tests/fs/permissions.test.ts +2 -2
- package/tests/fs/stat.test.ts +42 -0
- package/tests/fs/times.test.ts +28 -28
- package/tests/setup/cow+fetch.ts +4 -2
package/dist/backends/fetch.js
CHANGED
|
@@ -62,7 +62,7 @@ export class FetchFS extends IndexFS {
|
|
|
62
62
|
if (baseUrl.at(-1) != '/') {
|
|
63
63
|
baseUrl += '/';
|
|
64
64
|
}
|
|
65
|
-
super(typeof index != 'string' ? index : fetchFile(
|
|
65
|
+
super(typeof index != 'string' ? index : fetchFile(index, 'json', requestInit));
|
|
66
66
|
this.baseUrl = baseUrl;
|
|
67
67
|
this.requestInit = requestInit;
|
|
68
68
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { Ino } from '../inode.js';
|
|
2
1
|
import { StoreFS } from './store/fs.js';
|
|
3
2
|
import { SimpleTransaction, type SimpleSyncStore } from './store/simple.js';
|
|
4
3
|
/**
|
|
5
4
|
* A simple in-memory store
|
|
6
5
|
*/
|
|
7
|
-
export declare class InMemoryStore extends Map<
|
|
6
|
+
export declare class InMemoryStore extends Map<bigint, Uint8Array> implements SimpleSyncStore {
|
|
8
7
|
name: string;
|
|
9
8
|
constructor(name?: string);
|
|
10
9
|
sync(): Promise<void>;
|
package/dist/backends/overlay.js
CHANGED
|
@@ -50,7 +50,6 @@ import { Errno, ErrnoError } from '../error.js';
|
|
|
50
50
|
import { PreloadFile, parseFlag } from '../file.js';
|
|
51
51
|
import { FileSystem } from '../filesystem.js';
|
|
52
52
|
import { Mutexed } from '../mixins/mutexed.js';
|
|
53
|
-
import { Stats } from '../stats.js';
|
|
54
53
|
import { decodeUTF8, encodeUTF8 } from '../utils.js';
|
|
55
54
|
/** @internal */
|
|
56
55
|
const deletionLogPath = '/.deleted';
|
|
@@ -170,7 +169,7 @@ export class UnmutexedOverlayFS extends FileSystem {
|
|
|
170
169
|
if (this._deletedFiles.has(path)) {
|
|
171
170
|
throw ErrnoError.With('ENOENT', path, 'stat');
|
|
172
171
|
}
|
|
173
|
-
const oldStat =
|
|
172
|
+
const oldStat = await this.readable.stat(path);
|
|
174
173
|
// Make the oldStat's mode writable.
|
|
175
174
|
oldStat.mode |= 0o222;
|
|
176
175
|
return oldStat;
|
|
@@ -185,7 +184,7 @@ export class UnmutexedOverlayFS extends FileSystem {
|
|
|
185
184
|
if (this._deletedFiles.has(path)) {
|
|
186
185
|
throw ErrnoError.With('ENOENT', path, 'stat');
|
|
187
186
|
}
|
|
188
|
-
const oldStat =
|
|
187
|
+
const oldStat = this.readable.statSync(path);
|
|
189
188
|
// Make the oldStat's mode writable.
|
|
190
189
|
oldStat.mode |= 0o222;
|
|
191
190
|
return oldStat;
|
|
@@ -3,6 +3,7 @@ import type { ExtractProperties } from 'utilium';
|
|
|
3
3
|
import { type MountConfiguration } from '../../config.js';
|
|
4
4
|
import { File } from '../../file.js';
|
|
5
5
|
import { FileSystem, type FileSystemMetadata } from '../../filesystem.js';
|
|
6
|
+
import { Async } from '../../mixins/async.js';
|
|
6
7
|
import { Stats, type FileType } from '../../stats.js';
|
|
7
8
|
import type { Backend, FilesystemOf } from '../backend.js';
|
|
8
9
|
import * as RPC from './rpc.js';
|
|
@@ -51,21 +52,7 @@ export interface FSRequest<TMethod extends FSMethod = FSMethod> extends RPC.Requ
|
|
|
51
52
|
method: TMethod;
|
|
52
53
|
args: Parameters<FSMethods[TMethod]>;
|
|
53
54
|
}
|
|
54
|
-
declare const PortFS_base: import("../../index.js").Mixin<typeof FileSystem,
|
|
55
|
-
_sync?: FileSystem;
|
|
56
|
-
queueDone(): Promise<void>;
|
|
57
|
-
ready(): Promise<void>;
|
|
58
|
-
renameSync(oldPath: string, newPath: string): void;
|
|
59
|
-
statSync(path: string): Stats;
|
|
60
|
-
createFileSync(path: string, flag: string, mode: number): File;
|
|
61
|
-
openFileSync(path: string, flag: string): File;
|
|
62
|
-
unlinkSync(path: string): void;
|
|
63
|
-
rmdirSync(path: string): void;
|
|
64
|
-
mkdirSync(path: string, mode: number): void;
|
|
65
|
-
readdirSync(path: string): string[];
|
|
66
|
-
linkSync(srcpath: string, dstpath: string): void;
|
|
67
|
-
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
68
|
-
}>;
|
|
55
|
+
declare const PortFS_base: import("../../index.js").Mixin<typeof FileSystem, Async>;
|
|
69
56
|
/**
|
|
70
57
|
* PortFS lets you access an FS instance that is running in a port, or the other way around.
|
|
71
58
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { File } from '../../file.js';
|
|
1
2
|
import { FileSystem, type FileSystemMetadata } from '../../filesystem.js';
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
3
|
+
import { Inode } from '../../inode.js';
|
|
4
|
+
import type { Stats } from '../../stats.js';
|
|
4
5
|
import type { Store, Transaction } from './store.js';
|
|
5
|
-
import type { File } from '../../file.js';
|
|
6
6
|
/**
|
|
7
7
|
* A file system which uses a key-value store.
|
|
8
8
|
*
|
|
@@ -72,7 +72,7 @@ export declare class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
72
72
|
* @param filename The filename of the inode we are attempting to find, minus
|
|
73
73
|
* the parent.
|
|
74
74
|
*/
|
|
75
|
-
private
|
|
75
|
+
private _findInode;
|
|
76
76
|
/**
|
|
77
77
|
* Helper function for findINode.
|
|
78
78
|
* @param parent The parent directory of the file we are attempting to find.
|
|
@@ -80,56 +80,45 @@ export declare class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
80
80
|
* the parent.
|
|
81
81
|
* @return string The ID of the file's inode in the file system.
|
|
82
82
|
*/
|
|
83
|
-
protected
|
|
83
|
+
protected _findInodeSync(tx: Transaction, path: string, syscall: string, visited?: Set<string>): bigint;
|
|
84
84
|
/**
|
|
85
85
|
* Finds the Inode of `path`.
|
|
86
86
|
* @param path The path to look up.
|
|
87
87
|
* @todo memoize/cache
|
|
88
88
|
*/
|
|
89
|
-
private
|
|
89
|
+
private findInode;
|
|
90
90
|
/**
|
|
91
91
|
* Finds the Inode of `path`.
|
|
92
92
|
* @param path The path to look up.
|
|
93
93
|
* @return The Inode of the path p.
|
|
94
94
|
* @todo memoize/cache
|
|
95
95
|
*/
|
|
96
|
-
protected
|
|
96
|
+
protected findInodeSync(tx: Transaction, path: string, syscall: string, visited?: Set<string>): Inode;
|
|
97
97
|
/**
|
|
98
|
-
* Given
|
|
98
|
+
* Given an ID, retrieves the corresponding data.
|
|
99
99
|
* @param tx The transaction to use.
|
|
100
100
|
* @param path The corresponding path to the file (used for error messages).
|
|
101
101
|
* @param id The ID to look up.
|
|
102
102
|
*/
|
|
103
|
-
private
|
|
103
|
+
private get;
|
|
104
104
|
/**
|
|
105
|
-
* Given
|
|
105
|
+
* Given an ID, retrieves the corresponding data.
|
|
106
106
|
* @param tx The transaction to use.
|
|
107
107
|
* @param path The corresponding path to the file (used for error messages).
|
|
108
108
|
* @param id The ID to look up.
|
|
109
109
|
*/
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Given the Inode of a directory, retrieves the corresponding directory
|
|
113
|
-
* listing.
|
|
114
|
-
*/
|
|
115
|
-
private getDirListing;
|
|
116
|
-
/**
|
|
117
|
-
* Given the Inode of a directory, retrieves the corresponding directory listing.
|
|
118
|
-
*/
|
|
119
|
-
protected getDirListingSync(tx: Transaction, inode: Inode, p?: string): {
|
|
120
|
-
[fileName: string]: Ino;
|
|
121
|
-
};
|
|
110
|
+
private getSync;
|
|
122
111
|
/**
|
|
123
112
|
* Adds a new node under a random ID. Retries before giving up in
|
|
124
|
-
* the exceedingly unlikely chance that we try to reuse a random
|
|
113
|
+
* the exceedingly unlikely chance that we try to reuse a random id.
|
|
125
114
|
*/
|
|
126
|
-
private
|
|
115
|
+
private allocNew;
|
|
127
116
|
/**
|
|
128
117
|
* Creates a new node under a random ID. Retries before giving up in
|
|
129
|
-
* the exceedingly unlikely chance that we try to reuse a random
|
|
118
|
+
* the exceedingly unlikely chance that we try to reuse a random id.
|
|
130
119
|
* @return The ino that the data was stored under.
|
|
131
120
|
*/
|
|
132
|
-
|
|
121
|
+
private allocNewSync;
|
|
133
122
|
/**
|
|
134
123
|
* Commits a new file (well, a FILE or a DIRECTORY) to the file system with `mode`.
|
|
135
124
|
* Note: This will commit the transaction.
|
|
@@ -148,7 +137,7 @@ export declare class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
148
137
|
* @param data The data to store at the file's data node.
|
|
149
138
|
* @return The Inode for the new file.
|
|
150
139
|
*/
|
|
151
|
-
|
|
140
|
+
private commitNewSync;
|
|
152
141
|
/**
|
|
153
142
|
* Remove all traces of `path` from the file system.
|
|
154
143
|
* @param path The path to remove from the file system.
|
|
@@ -162,5 +151,5 @@ export declare class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
162
151
|
* @param isDir Does the path belong to a directory, or a file?
|
|
163
152
|
* @todo Update mtime.
|
|
164
153
|
*/
|
|
165
|
-
|
|
154
|
+
private removeSync;
|
|
166
155
|
}
|