@zenfs/core 0.9.3 → 0.9.4
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/filesystem.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare abstract class FileSystem {
|
|
|
39
39
|
*/
|
|
40
40
|
metadata(): FileSystemMetadata;
|
|
41
41
|
constructor(options?: object);
|
|
42
|
-
|
|
42
|
+
ready(): Promise<this>;
|
|
43
43
|
/**
|
|
44
44
|
* Asynchronous rename. No arguments other than a possible exception
|
|
45
45
|
* are given to the completion callback.
|
package/dist/filesystem.js
CHANGED
|
@@ -27,6 +27,9 @@ export class FileSystem {
|
|
|
27
27
|
constructor(options) {
|
|
28
28
|
// unused
|
|
29
29
|
}
|
|
30
|
+
async ready() {
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
30
33
|
/**
|
|
31
34
|
* Test whether or not the given path exists by checking with the file system.
|
|
32
35
|
*/
|
|
@@ -57,9 +60,6 @@ export class FileSystem {
|
|
|
57
60
|
*/
|
|
58
61
|
export function Sync(FS) {
|
|
59
62
|
class _SyncFileSystem extends FS {
|
|
60
|
-
async ready() {
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
63
|
async exists(path, cred) {
|
|
64
64
|
return this.existsSync(path, cred);
|
|
65
65
|
}
|
|
@@ -121,6 +121,7 @@ export function Async(FS) {
|
|
|
121
121
|
}
|
|
122
122
|
async ready() {
|
|
123
123
|
await this._sync.ready();
|
|
124
|
+
await super.ready();
|
|
124
125
|
if (this._isInitialized) {
|
|
125
126
|
return this;
|
|
126
127
|
}
|
|
@@ -195,10 +196,9 @@ export function Async(FS) {
|
|
|
195
196
|
}
|
|
196
197
|
else {
|
|
197
198
|
const asyncFile = await this.openFile(p, parseFlag('r'), rootCred);
|
|
198
|
-
const syncFile = this._sync.createFileSync(p, parseFlag('w'), stats.mode,
|
|
199
|
+
const syncFile = this._sync.createFileSync(p, parseFlag('w'), stats.mode, stats.cred());
|
|
199
200
|
try {
|
|
200
|
-
const
|
|
201
|
-
const buffer = new Uint8Array(size);
|
|
201
|
+
const buffer = new Uint8Array(stats.size);
|
|
202
202
|
await asyncFile.read(buffer);
|
|
203
203
|
syncFile.writeSync(buffer);
|
|
204
204
|
}
|
package/package.json
CHANGED
|
@@ -135,7 +135,7 @@ export class AsyncStoreFS extends Async(FileSystem) {
|
|
|
135
135
|
private _cache?: LRUCache<string, Ino>;
|
|
136
136
|
_sync: FileSystem;
|
|
137
137
|
|
|
138
|
-
public async ready() {
|
|
138
|
+
public async ready(): Promise<this> {
|
|
139
139
|
if (this._options.lruCacheSize > 0) {
|
|
140
140
|
this._cache = new LRUCache(this._options.lruCacheSize);
|
|
141
141
|
}
|
package/src/filesystem.ts
CHANGED
|
@@ -59,7 +59,9 @@ export abstract class FileSystem {
|
|
|
59
59
|
// unused
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
public
|
|
62
|
+
public async ready(): Promise<this> {
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
63
65
|
|
|
64
66
|
/**
|
|
65
67
|
* Asynchronous rename. No arguments other than a possible exception
|
|
@@ -218,10 +220,6 @@ declare abstract class SyncFileSystem extends FileSystem {
|
|
|
218
220
|
*/
|
|
219
221
|
export function Sync<T extends abstract new (...args) => FileSystem>(FS: T): (abstract new (...args) => SyncFileSystem) & T {
|
|
220
222
|
abstract class _SyncFileSystem extends FS implements SyncFileSystem {
|
|
221
|
-
public async ready(): Promise<this> {
|
|
222
|
-
return this;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
223
|
public async exists(path: string, cred: Cred): Promise<boolean> {
|
|
226
224
|
return this.existsSync(path, cred);
|
|
227
225
|
}
|
|
@@ -325,6 +323,7 @@ export function Async<T extends abstract new (...args) => FileSystem>(FS: T): (a
|
|
|
325
323
|
|
|
326
324
|
public async ready(): Promise<this> {
|
|
327
325
|
await this._sync.ready();
|
|
326
|
+
await super.ready();
|
|
328
327
|
if (this._isInitialized) {
|
|
329
328
|
return this;
|
|
330
329
|
}
|
|
@@ -410,10 +409,9 @@ export function Async<T extends abstract new (...args) => FileSystem>(FS: T): (a
|
|
|
410
409
|
}
|
|
411
410
|
} else {
|
|
412
411
|
const asyncFile = await this.openFile(p, parseFlag('r'), rootCred);
|
|
413
|
-
const syncFile = this._sync.createFileSync(p, parseFlag('w'), stats.mode,
|
|
412
|
+
const syncFile = this._sync.createFileSync(p, parseFlag('w'), stats.mode, stats.cred());
|
|
414
413
|
try {
|
|
415
|
-
const
|
|
416
|
-
const buffer = new Uint8Array(size);
|
|
414
|
+
const buffer = new Uint8Array(stats.size);
|
|
417
415
|
await asyncFile.read(buffer);
|
|
418
416
|
syncFile.writeSync(buffer);
|
|
419
417
|
} finally {
|