@gallop.software/studio 2.3.36 → 2.3.38
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/server/index.js +40 -11
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -1435,6 +1435,7 @@ async function handleRenameStream(request) {
|
|
|
1435
1435
|
const isImagePath = isImageFile(path6.basename(oldPath));
|
|
1436
1436
|
let hasLocalItem = false;
|
|
1437
1437
|
let isFile = true;
|
|
1438
|
+
let isVirtualFolder = false;
|
|
1438
1439
|
try {
|
|
1439
1440
|
const stats = await fs6.stat(absoluteOldPath);
|
|
1440
1441
|
hasLocalItem = true;
|
|
@@ -1443,12 +1444,20 @@ async function handleRenameStream(request) {
|
|
|
1443
1444
|
const meta2 = await loadMeta();
|
|
1444
1445
|
const oldKey2 = "/" + oldRelativePath;
|
|
1445
1446
|
const entry2 = meta2[oldKey2];
|
|
1446
|
-
if (
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1447
|
+
if (entry2) {
|
|
1448
|
+
isFile = true;
|
|
1449
|
+
} else {
|
|
1450
|
+
const folderPrefix = oldKey2 + "/";
|
|
1451
|
+
const hasChildrenInMeta = Object.keys(meta2).some((key) => key.startsWith(folderPrefix));
|
|
1452
|
+
if (hasChildrenInMeta) {
|
|
1453
|
+
isFile = false;
|
|
1454
|
+
isVirtualFolder = true;
|
|
1455
|
+
} else {
|
|
1456
|
+
sendEvent({ type: "error", message: "File or folder not found" });
|
|
1457
|
+
controller.close();
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1450
1460
|
}
|
|
1451
|
-
isFile = true;
|
|
1452
1461
|
}
|
|
1453
1462
|
const sanitizedName = isFile ? slugifyFilename(newName) : slugifyFolderName(newName);
|
|
1454
1463
|
if (!sanitizedName) {
|
|
@@ -1470,12 +1479,23 @@ async function handleRenameStream(request) {
|
|
|
1470
1479
|
return;
|
|
1471
1480
|
}
|
|
1472
1481
|
}
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1482
|
+
if (!isVirtualFolder) {
|
|
1483
|
+
try {
|
|
1484
|
+
await fs6.access(absoluteNewPath);
|
|
1485
|
+
sendEvent({ type: "error", message: "An item with this name already exists" });
|
|
1486
|
+
controller.close();
|
|
1487
|
+
return;
|
|
1488
|
+
} catch {
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
if (isVirtualFolder) {
|
|
1492
|
+
const newPrefix = "/" + newRelativePath + "/";
|
|
1493
|
+
const hasConflict = Object.keys(meta).some((key) => key.startsWith(newPrefix));
|
|
1494
|
+
if (hasConflict) {
|
|
1495
|
+
sendEvent({ type: "error", message: "A folder with this name already exists" });
|
|
1496
|
+
controller.close();
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1479
1499
|
}
|
|
1480
1500
|
if (!isFile) {
|
|
1481
1501
|
const oldPrefix = "/" + oldRelativePath + "/";
|
|
@@ -1491,6 +1511,15 @@ async function handleRenameStream(request) {
|
|
|
1491
1511
|
sendEvent({ type: "start", total, message: `Renaming folder with ${itemsToUpdate.length} item(s)...` });
|
|
1492
1512
|
if (hasLocalItem) {
|
|
1493
1513
|
await fs6.rename(absoluteOldPath, absoluteNewPath);
|
|
1514
|
+
const imagesDir = getPublicPath("/images");
|
|
1515
|
+
const oldThumbFolder = path6.join(imagesDir, oldRelativePath);
|
|
1516
|
+
const newThumbFolder = path6.join(imagesDir, newRelativePath);
|
|
1517
|
+
try {
|
|
1518
|
+
await fs6.access(oldThumbFolder);
|
|
1519
|
+
await fs6.mkdir(path6.dirname(newThumbFolder), { recursive: true });
|
|
1520
|
+
await fs6.rename(oldThumbFolder, newThumbFolder);
|
|
1521
|
+
} catch {
|
|
1522
|
+
}
|
|
1494
1523
|
}
|
|
1495
1524
|
sendEvent({ type: "progress", current: 1, total, renamed: 1, message: "Renamed folder" });
|
|
1496
1525
|
let renamed = 1;
|