@zenfs/core 0.0.10 → 0.0.12
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/AsyncMirror.js +5 -5
- package/dist/backends/Locked.d.ts +7 -8
- package/dist/backends/Locked.js +12 -12
- package/dist/backends/OverlayFS.js +12 -11
- package/dist/browser.min.js +6 -6
- package/dist/browser.min.js.map +3 -3
- package/dist/emulation/promises.js +19 -4
- package/dist/emulation/sync.js +19 -4
- package/dist/filesystem.d.ts +12 -20
- package/dist/filesystem.js +9 -15
- package/dist/utils.d.ts +6 -10
- package/dist/utils.js +4 -2
- package/package.json +1 -1
|
@@ -101,10 +101,10 @@ export class AsyncMirror extends SynchronousFileSystem {
|
|
|
101
101
|
}
|
|
102
102
|
_syncSync(fd) {
|
|
103
103
|
const stats = fd.getStats();
|
|
104
|
-
this._sync.writeFileSync(fd.getPath(), fd.getBuffer(),
|
|
104
|
+
this._sync.writeFileSync(fd.getPath(), fd.getBuffer(), FileFlag.getFileFlag('w'), stats.mode, stats.getCred(0, 0));
|
|
105
105
|
this.enqueueOp({
|
|
106
106
|
apiMethod: 'writeFile',
|
|
107
|
-
arguments: [fd.getPath(), fd.getBuffer(),
|
|
107
|
+
arguments: [fd.getPath(), fd.getBuffer(), fd.getFlag(), stats.mode, stats.getCred(0, 0)],
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
renameSync(oldPath, newPath, cred) {
|
|
@@ -121,7 +121,7 @@ export class AsyncMirror extends SynchronousFileSystem {
|
|
|
121
121
|
// Sanity check: Is this open/close permitted?
|
|
122
122
|
const fd = this._sync.openSync(p, flag, mode, cred);
|
|
123
123
|
fd.closeSync();
|
|
124
|
-
return new MirrorFile(this, p, flag, this._sync.statSync(p, cred), this._sync.readFileSync(p,
|
|
124
|
+
return new MirrorFile(this, p, flag, this._sync.statSync(p, cred), this._sync.readFileSync(p, FileFlag.getFileFlag('r'), cred));
|
|
125
125
|
}
|
|
126
126
|
unlinkSync(p, cred) {
|
|
127
127
|
this._sync.unlinkSync(p, cred);
|
|
@@ -188,8 +188,8 @@ export class AsyncMirror extends SynchronousFileSystem {
|
|
|
188
188
|
yield copyItem(join(p, file));
|
|
189
189
|
}
|
|
190
190
|
}), copyFile = (p, mode) => __awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
const data = yield this._async.readFile(p,
|
|
192
|
-
this._sync.writeFileSync(p, data,
|
|
191
|
+
const data = yield this._async.readFile(p, FileFlag.getFileFlag('r'), Cred.Root);
|
|
192
|
+
this._sync.writeFileSync(p, data, FileFlag.getFileFlag('w'), mode, Cred.Root);
|
|
193
193
|
}), copyItem = (p) => __awaiter(this, void 0, void 0, function* () {
|
|
194
194
|
const stats = yield this._async.stat(p, Cred.Root);
|
|
195
195
|
if (stats.isDirectory()) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { FileContents, FileSystem, FileSystemMetadata } from '../filesystem.js';
|
|
1
|
+
import { FileSystem, FileSystemMetadata } from '../filesystem.js';
|
|
3
2
|
import { FileFlag } from '../file.js';
|
|
4
3
|
import { Stats } from '../stats.js';
|
|
5
4
|
import { File } from '../file.js';
|
|
@@ -43,12 +42,12 @@ export default class LockedFS<T extends FileSystem> implements FileSystem {
|
|
|
43
42
|
realpathSync(p: string, cred: Cred): string;
|
|
44
43
|
truncate(p: string, len: number, cred: Cred): Promise<void>;
|
|
45
44
|
truncateSync(p: string, len: number, cred: Cred): void;
|
|
46
|
-
readFile(fname: string,
|
|
47
|
-
readFileSync(fname: string,
|
|
48
|
-
writeFile(fname: string, data:
|
|
49
|
-
writeFileSync(fname: string, data:
|
|
50
|
-
appendFile(fname: string, data:
|
|
51
|
-
appendFileSync(fname: string, data:
|
|
45
|
+
readFile(fname: string, flag: FileFlag, cred: Cred): Promise<Uint8Array>;
|
|
46
|
+
readFileSync(fname: string, flag: FileFlag, cred: Cred): Uint8Array;
|
|
47
|
+
writeFile(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): Promise<void>;
|
|
48
|
+
writeFileSync(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): void;
|
|
49
|
+
appendFile(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): Promise<void>;
|
|
50
|
+
appendFileSync(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): void;
|
|
52
51
|
chmod(p: string, mode: number, cred: Cred): Promise<void>;
|
|
53
52
|
chmodSync(p: string, mode: number, cred: Cred): void;
|
|
54
53
|
chown(p: string, new_uid: number, new_gid: number, cred: Cred): Promise<void>;
|
package/dist/backends/Locked.js
CHANGED
|
@@ -180,45 +180,45 @@ export default class LockedFS {
|
|
|
180
180
|
}
|
|
181
181
|
return this._fs.truncateSync(p, len, cred);
|
|
182
182
|
}
|
|
183
|
-
readFile(fname,
|
|
183
|
+
readFile(fname, flag, cred) {
|
|
184
184
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
185
|
yield this._mu.lock(fname);
|
|
186
|
-
const data = yield this._fs.readFile(fname,
|
|
186
|
+
const data = yield this._fs.readFile(fname, flag, cred);
|
|
187
187
|
this._mu.unlock(fname);
|
|
188
188
|
return data;
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
|
-
readFileSync(fname,
|
|
191
|
+
readFileSync(fname, flag, cred) {
|
|
192
192
|
if (this._mu.isLocked(fname)) {
|
|
193
193
|
throw new Error('invalid sync call');
|
|
194
194
|
}
|
|
195
|
-
return this._fs.readFileSync(fname,
|
|
195
|
+
return this._fs.readFileSync(fname, flag, cred);
|
|
196
196
|
}
|
|
197
|
-
writeFile(fname, data,
|
|
197
|
+
writeFile(fname, data, flag, mode, cred) {
|
|
198
198
|
return __awaiter(this, void 0, void 0, function* () {
|
|
199
199
|
yield this._mu.lock(fname);
|
|
200
|
-
yield this._fs.writeFile(fname, data,
|
|
200
|
+
yield this._fs.writeFile(fname, data, flag, mode, cred);
|
|
201
201
|
this._mu.unlock(fname);
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
|
-
writeFileSync(fname, data,
|
|
204
|
+
writeFileSync(fname, data, flag, mode, cred) {
|
|
205
205
|
if (this._mu.isLocked(fname)) {
|
|
206
206
|
throw new Error('invalid sync call');
|
|
207
207
|
}
|
|
208
|
-
return this._fs.writeFileSync(fname, data,
|
|
208
|
+
return this._fs.writeFileSync(fname, data, flag, mode, cred);
|
|
209
209
|
}
|
|
210
|
-
appendFile(fname, data,
|
|
210
|
+
appendFile(fname, data, flag, mode, cred) {
|
|
211
211
|
return __awaiter(this, void 0, void 0, function* () {
|
|
212
212
|
yield this._mu.lock(fname);
|
|
213
|
-
yield this._fs.appendFile(fname, data,
|
|
213
|
+
yield this._fs.appendFile(fname, data, flag, mode, cred);
|
|
214
214
|
this._mu.unlock(fname);
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
|
-
appendFileSync(fname, data,
|
|
217
|
+
appendFileSync(fname, data, flag, mode, cred) {
|
|
218
218
|
if (this._mu.isLocked(fname)) {
|
|
219
219
|
throw new Error('invalid sync call');
|
|
220
220
|
}
|
|
221
|
-
return this._fs.appendFileSync(fname, data,
|
|
221
|
+
return this._fs.appendFileSync(fname, data, flag, mode, cred);
|
|
222
222
|
}
|
|
223
223
|
chmod(p, mode, cred) {
|
|
224
224
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -16,6 +16,7 @@ import LockedFS from './Locked.js';
|
|
|
16
16
|
import { resolve, dirname } from '../emulation/path.js';
|
|
17
17
|
import { Cred } from '../cred.js';
|
|
18
18
|
import { CreateBackend } from './backend.js';
|
|
19
|
+
import { decode, encode } from '../utils.js';
|
|
19
20
|
/**
|
|
20
21
|
* @internal
|
|
21
22
|
*/
|
|
@@ -105,13 +106,13 @@ export class UnlockedOverlayFS extends BaseFileSystem {
|
|
|
105
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
107
|
const stats = file.getStats();
|
|
107
108
|
yield this.createParentDirectoriesAsync(file.getPath(), stats.getCred(0, 0));
|
|
108
|
-
return this._writable.writeFile(file.getPath(), file.getBuffer(),
|
|
109
|
+
return this._writable.writeFile(file.getPath(), file.getBuffer(), getFlag('w'), stats.mode, stats.getCred(0, 0));
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
112
|
_syncSync(file) {
|
|
112
113
|
const stats = file.getStats();
|
|
113
114
|
this.createParentDirectories(file.getPath(), stats.getCred(0, 0));
|
|
114
|
-
this._writable.writeFileSync(file.getPath(), file.getBuffer(),
|
|
115
|
+
this._writable.writeFileSync(file.getPath(), file.getBuffer(), getFlag('w'), stats.mode, stats.getCred(0, 0));
|
|
115
116
|
}
|
|
116
117
|
/**
|
|
117
118
|
* **INTERNAL METHOD**
|
|
@@ -126,8 +127,8 @@ export class UnlockedOverlayFS extends BaseFileSystem {
|
|
|
126
127
|
}
|
|
127
128
|
// Read deletion log, process into metadata.
|
|
128
129
|
try {
|
|
129
|
-
const data =
|
|
130
|
-
this._deleteLog = data;
|
|
130
|
+
const data = yield this._writable.readFile(deletionLogPath, getFlag('r'), Cred.Root);
|
|
131
|
+
this._deleteLog = decode(data);
|
|
131
132
|
}
|
|
132
133
|
catch (err) {
|
|
133
134
|
if (err.errno !== ErrorCode.ENOENT) {
|
|
@@ -195,7 +196,7 @@ export class UnlockedOverlayFS extends BaseFileSystem {
|
|
|
195
196
|
if ((yield this.exists(newPath, cred)) && (yield this.stat(newPath, cred)).isDirectory()) {
|
|
196
197
|
throw ApiError.EISDIR(newPath);
|
|
197
198
|
}
|
|
198
|
-
yield this.writeFile(newPath, yield this.readFile(oldPath,
|
|
199
|
+
yield this.writeFile(newPath, yield this.readFile(oldPath, getFlag('r'), cred), getFlag('w'), oldStats.mode, cred);
|
|
199
200
|
}
|
|
200
201
|
if (oldPath !== newPath && (yield this.exists(oldPath, cred))) {
|
|
201
202
|
yield this.unlink(oldPath, cred);
|
|
@@ -250,7 +251,7 @@ export class UnlockedOverlayFS extends BaseFileSystem {
|
|
|
250
251
|
if (this.existsSync(newPath, cred) && this.statSync(newPath, cred).isDirectory()) {
|
|
251
252
|
throw ApiError.EISDIR(newPath);
|
|
252
253
|
}
|
|
253
|
-
this.writeFileSync(newPath, this.readFileSync(oldPath,
|
|
254
|
+
this.writeFileSync(newPath, this.readFileSync(oldPath, getFlag('r'), cred), getFlag('w'), oldStats.mode, cred);
|
|
254
255
|
}
|
|
255
256
|
if (oldPath !== newPath && this.existsSync(oldPath, cred)) {
|
|
256
257
|
this.unlinkSync(oldPath, cred);
|
|
@@ -308,7 +309,7 @@ export class UnlockedOverlayFS extends BaseFileSystem {
|
|
|
308
309
|
}
|
|
309
310
|
else {
|
|
310
311
|
// Create an OverlayFile.
|
|
311
|
-
const buf = yield this._readable.readFile(p,
|
|
312
|
+
const buf = yield this._readable.readFile(p, getFlag('r'), cred);
|
|
312
313
|
const stats = Stats.clone(yield this._readable.stat(p, cred));
|
|
313
314
|
stats.mode = mode;
|
|
314
315
|
return new OverlayFile(this, p, flag, stats, buf);
|
|
@@ -345,7 +346,7 @@ export class UnlockedOverlayFS extends BaseFileSystem {
|
|
|
345
346
|
}
|
|
346
347
|
else {
|
|
347
348
|
// Create an OverlayFile.
|
|
348
|
-
const buf = this._readable.readFileSync(p,
|
|
349
|
+
const buf = this._readable.readFileSync(p, getFlag('r'), cred);
|
|
349
350
|
const stats = Stats.clone(this._readable.statSync(p, cred));
|
|
350
351
|
stats.mode = mode;
|
|
351
352
|
return new OverlayFile(this, p, flag, stats, buf);
|
|
@@ -580,7 +581,7 @@ export class UnlockedOverlayFS extends BaseFileSystem {
|
|
|
580
581
|
else {
|
|
581
582
|
this._deleteLogUpdatePending = true;
|
|
582
583
|
this._writable
|
|
583
|
-
.writeFile(deletionLogPath, this._deleteLog,
|
|
584
|
+
.writeFile(deletionLogPath, encode(this._deleteLog), FileFlag.getFileFlag('w'), 0o644, cred)
|
|
584
585
|
.then(() => {
|
|
585
586
|
if (this._deleteLogUpdateNeeded) {
|
|
586
587
|
this._deleteLogUpdateNeeded = false;
|
|
@@ -681,7 +682,7 @@ export class UnlockedOverlayFS extends BaseFileSystem {
|
|
|
681
682
|
this._writable.mkdirSync(p, pStats.mode, cred);
|
|
682
683
|
}
|
|
683
684
|
else {
|
|
684
|
-
this.writeFileSync(p, this._readable.readFileSync(p,
|
|
685
|
+
this.writeFileSync(p, this._readable.readFileSync(p, getFlag('r'), cred), getFlag('w'), pStats.mode, cred);
|
|
685
686
|
}
|
|
686
687
|
}
|
|
687
688
|
copyToWritableAsync(p, cred) {
|
|
@@ -691,7 +692,7 @@ export class UnlockedOverlayFS extends BaseFileSystem {
|
|
|
691
692
|
yield this._writable.mkdir(p, pStats.mode, cred);
|
|
692
693
|
}
|
|
693
694
|
else {
|
|
694
|
-
yield this.writeFile(p, yield this._readable.readFile(p,
|
|
695
|
+
yield this.writeFile(p, yield this._readable.readFile(p, getFlag('r'), cred), getFlag('w'), pStats.mode, cred);
|
|
695
696
|
}
|
|
696
697
|
});
|
|
697
698
|
}
|