@componentor/fs 3.0.48 → 3.0.49
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 +32 -9
- package/dist/index.js.map +1 -1
- package/dist/workers/repair.worker.js +32 -9
- package/dist/workers/repair.worker.js.map +1 -1
- package/dist/workers/server.worker.js +32 -9
- package/dist/workers/server.worker.js.map +1 -1
- package/dist/workers/sync-relay.worker.js +32 -9
- package/dist/workers/sync-relay.worker.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +9 -0
|
@@ -861,6 +861,7 @@ var VFSEngine = class {
|
|
|
861
861
|
this.writeInode(existingIdx, inode);
|
|
862
862
|
tInode = this.debug ? performance.now() : 0;
|
|
863
863
|
} else {
|
|
864
|
+
if (this.isImplicitDirectory(path)) return { status: CODE_TO_STATUS.EISDIR };
|
|
864
865
|
const mode = DEFAULT_FILE_MODE & ~(this.umask & 511);
|
|
865
866
|
this.createInode(path, INODE_TYPE.FILE, mode, data.byteLength, data);
|
|
866
867
|
tAlloc = this.debug ? performance.now() : 0;
|
|
@@ -1150,15 +1151,33 @@ var VFSEngine = class {
|
|
|
1150
1151
|
newPath = this.normalizePath(newPath);
|
|
1151
1152
|
const idx = this.pathIndex.get(oldPath);
|
|
1152
1153
|
if (idx === void 0) return { status: CODE_TO_STATUS.ENOENT };
|
|
1154
|
+
if (oldPath === newPath) return { status: 0 };
|
|
1153
1155
|
const parentStatus = this.ensureParent(newPath);
|
|
1154
1156
|
if (parentStatus !== 0) return { status: parentStatus };
|
|
1155
1157
|
const existingIdx = this.pathIndex.get(newPath);
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1158
|
+
const targetIsImplicitDir = existingIdx === void 0 && this.isImplicitDirectory(newPath);
|
|
1159
|
+
if (existingIdx !== void 0 || targetIsImplicitDir) {
|
|
1160
|
+
let cleanDescendants = targetIsImplicitDir;
|
|
1161
|
+
if (existingIdx !== void 0) {
|
|
1162
|
+
const existingInode = this.readInode(existingIdx);
|
|
1163
|
+
cleanDescendants = existingInode.type === INODE_TYPE.DIRECTORY;
|
|
1164
|
+
this.freeBlockRange(existingInode.firstBlock, existingInode.blockCount);
|
|
1165
|
+
existingInode.type = INODE_TYPE.FREE;
|
|
1166
|
+
this.writeInode(existingIdx, existingInode);
|
|
1167
|
+
this.pathIndex.delete(newPath);
|
|
1168
|
+
if (existingIdx < this.freeInodeHint) this.freeInodeHint = existingIdx;
|
|
1169
|
+
}
|
|
1170
|
+
if (cleanDescendants) {
|
|
1171
|
+
for (const desc of this.getAllDescendants(newPath)) {
|
|
1172
|
+
const descIdx = this.pathIndex.get(desc);
|
|
1173
|
+
const descInode = this.readInode(descIdx);
|
|
1174
|
+
this.freeBlockRange(descInode.firstBlock, descInode.blockCount);
|
|
1175
|
+
descInode.type = INODE_TYPE.FREE;
|
|
1176
|
+
this.writeInode(descIdx, descInode);
|
|
1177
|
+
this.pathIndex.delete(desc);
|
|
1178
|
+
if (descIdx < this.freeInodeHint) this.freeInodeHint = descIdx;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1162
1181
|
}
|
|
1163
1182
|
const inode = this.readInode(idx);
|
|
1164
1183
|
const { offset: pathOff, length: pathLen } = this.appendPath(newPath);
|
|
@@ -1262,7 +1281,7 @@ var VFSEngine = class {
|
|
|
1262
1281
|
if (srcIdx === void 0) return { status: CODE_TO_STATUS.ENOENT };
|
|
1263
1282
|
const srcInode = this.readInode(srcIdx);
|
|
1264
1283
|
if (srcInode.type === INODE_TYPE.DIRECTORY) return { status: CODE_TO_STATUS.EISDIR };
|
|
1265
|
-
if (flags & 1 && this.pathIndex.has(destPath)) {
|
|
1284
|
+
if (flags & 1 && (this.pathIndex.has(destPath) || this.isImplicitDirectory(destPath))) {
|
|
1266
1285
|
return { status: CODE_TO_STATUS.EEXIST };
|
|
1267
1286
|
}
|
|
1268
1287
|
if (srcPath === destPath) return { status: 0 };
|
|
@@ -1371,7 +1390,9 @@ var VFSEngine = class {
|
|
|
1371
1390
|
// ---- SYMLINK ----
|
|
1372
1391
|
symlink(target, linkPath) {
|
|
1373
1392
|
linkPath = this.normalizePath(linkPath);
|
|
1374
|
-
if (this.pathIndex.has(linkPath)
|
|
1393
|
+
if (this.pathIndex.has(linkPath) || this.isImplicitDirectory(linkPath)) {
|
|
1394
|
+
return { status: CODE_TO_STATUS.EEXIST };
|
|
1395
|
+
}
|
|
1375
1396
|
const parentStatus = this.ensureParent(linkPath);
|
|
1376
1397
|
if (parentStatus !== 0) return { status: parentStatus };
|
|
1377
1398
|
const targetBytes = encoder.encode(target);
|
|
@@ -1397,7 +1418,9 @@ var VFSEngine = class {
|
|
|
1397
1418
|
if (srcIdx === void 0) return { status: CODE_TO_STATUS.ENOENT };
|
|
1398
1419
|
const srcInode = this.readInode(srcIdx);
|
|
1399
1420
|
if (srcInode.type === INODE_TYPE.DIRECTORY) return { status: CODE_TO_STATUS.EPERM };
|
|
1400
|
-
if (this.pathIndex.has(newPath)
|
|
1421
|
+
if (this.pathIndex.has(newPath) || this.isImplicitDirectory(newPath)) {
|
|
1422
|
+
return { status: CODE_TO_STATUS.EEXIST };
|
|
1423
|
+
}
|
|
1401
1424
|
const result = this.copy(existingPath, newPath);
|
|
1402
1425
|
if (result.status !== 0) return result;
|
|
1403
1426
|
srcInode.nlink++;
|