@gallop.software/studio 0.1.109 → 0.1.110

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.
@@ -471,6 +471,21 @@ async function handleListFolders() {
471
471
  folderSet.add(current);
472
472
  }
473
473
  }
474
+ async function scanDir(dir, relativePath) {
475
+ try {
476
+ const entries = await _fs.promises.readdir(dir, { withFileTypes: true });
477
+ for (const entry of entries) {
478
+ if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "images") {
479
+ const folderRelPath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
480
+ folderSet.add(folderRelPath);
481
+ await scanDir(_path2.default.join(dir, entry.name), folderRelPath);
482
+ }
483
+ }
484
+ } catch (e10) {
485
+ }
486
+ }
487
+ const publicDir = _path2.default.join(process.cwd(), "public");
488
+ await scanDir(publicDir, "");
474
489
  const folders = [];
475
490
  folders.push({ path: "public", name: "public", depth: 0 });
476
491
  const sortedFolders = Array.from(folderSet).sort();
@@ -607,7 +622,7 @@ async function handleUpload(request) {
607
622
  w: metadata.width || 0,
608
623
  h: metadata.height || 0
609
624
  };
610
- } catch (e10) {
625
+ } catch (e11) {
611
626
  meta[imageKey] = { w: 0, h: 0 };
612
627
  }
613
628
  } else {
@@ -656,7 +671,7 @@ async function handleDelete(request) {
656
671
  const absoluteThumbPath = _path2.default.join(process.cwd(), "public", thumbPath);
657
672
  try {
658
673
  await _fs.promises.unlink(absoluteThumbPath);
659
- } catch (e11) {
674
+ } catch (e12) {
660
675
  }
661
676
  }
662
677
  }
@@ -672,14 +687,14 @@ async function handleDelete(request) {
672
687
  const absoluteThumbPath = _path2.default.join(process.cwd(), "public", thumbPath);
673
688
  try {
674
689
  await _fs.promises.unlink(absoluteThumbPath);
675
- } catch (e12) {
690
+ } catch (e13) {
676
691
  }
677
692
  }
678
693
  }
679
694
  delete meta[imageKey];
680
695
  }
681
696
  }
682
- } catch (e13) {
697
+ } catch (e14) {
683
698
  if (entry) {
684
699
  delete meta[imageKey];
685
700
  } else {
@@ -732,7 +747,7 @@ async function handleCreateFolder(request) {
732
747
  try {
733
748
  await _fs.promises.access(folderPath);
734
749
  return _server.NextResponse.json({ error: "A folder with this name already exists" }, { status: 400 });
735
- } catch (e14) {
750
+ } catch (e15) {
736
751
  }
737
752
  await _fs.promises.mkdir(folderPath, { recursive: true });
738
753
  return _server.NextResponse.json({ success: true, path: _path2.default.join(safePath, sanitizedName) });
@@ -760,13 +775,13 @@ async function handleRename(request) {
760
775
  }
761
776
  try {
762
777
  await _fs.promises.access(absoluteOldPath);
763
- } catch (e15) {
778
+ } catch (e16) {
764
779
  return _server.NextResponse.json({ error: "File or folder not found" }, { status: 404 });
765
780
  }
766
781
  try {
767
782
  await _fs.promises.access(absoluteNewPath);
768
783
  return _server.NextResponse.json({ error: "An item with this name already exists" }, { status: 400 });
769
- } catch (e16) {
784
+ } catch (e17) {
770
785
  }
771
786
  const stats = await _fs.promises.stat(absoluteOldPath);
772
787
  const isFile = stats.isFile();
@@ -788,7 +803,7 @@ async function handleRename(request) {
788
803
  await _fs.promises.mkdir(_path2.default.dirname(newThumbPath), { recursive: true });
789
804
  try {
790
805
  await _fs.promises.rename(oldThumbPath, newThumbPath);
791
- } catch (e17) {
806
+ } catch (e18) {
792
807
  }
793
808
  }
794
809
  delete meta[oldKey];
@@ -903,7 +918,7 @@ async function handleMoveStream(request) {
903
918
  await deleteFromCdn(oldKey, hasProcessedThumbnails);
904
919
  try {
905
920
  await _fs.promises.unlink(newAbsolutePath);
906
- } catch (e18) {
921
+ } catch (e19) {
907
922
  }
908
923
  if (hasProcessedThumbnails) {
909
924
  await deleteLocalThumbnails(newKey);
@@ -920,7 +935,7 @@ async function handleMoveStream(request) {
920
935
  }
921
936
  try {
922
937
  await _fs.promises.access(absolutePath);
923
- } catch (e19) {
938
+ } catch (e20) {
924
939
  errors.push(`${itemName} not found`);
925
940
  continue;
926
941
  }
@@ -928,7 +943,7 @@ async function handleMoveStream(request) {
928
943
  await _fs.promises.access(newAbsolutePath);
929
944
  errors.push(`${itemName} already exists in destination`);
930
945
  continue;
931
- } catch (e20) {
946
+ } catch (e21) {
932
947
  }
933
948
  await _fs.promises.rename(absolutePath, newAbsolutePath);
934
949
  const stats = await _fs.promises.stat(newAbsolutePath);
@@ -941,7 +956,7 @@ async function handleMoveStream(request) {
941
956
  await _fs.promises.mkdir(_path2.default.dirname(newThumbPath), { recursive: true });
942
957
  try {
943
958
  await _fs.promises.rename(oldThumbPath, newThumbPath);
944
- } catch (e21) {
959
+ } catch (e22) {
945
960
  }
946
961
  }
947
962
  delete meta[oldKey];
@@ -1061,7 +1076,7 @@ async function handleSync(request) {
1061
1076
  ContentType: getContentType(thumbPath)
1062
1077
  })
1063
1078
  );
1064
- } catch (e22) {
1079
+ } catch (e23) {
1065
1080
  }
1066
1081
  }
1067
1082
  entry.c = cdnIndex;
@@ -1069,12 +1084,12 @@ async function handleSync(request) {
1069
1084
  const localPath = _path2.default.join(process.cwd(), "public", thumbPath);
1070
1085
  try {
1071
1086
  await _fs.promises.unlink(localPath);
1072
- } catch (e23) {
1087
+ } catch (e24) {
1073
1088
  }
1074
1089
  }
1075
1090
  try {
1076
1091
  await _fs.promises.unlink(originalLocalPath);
1077
- } catch (e24) {
1092
+ } catch (e25) {
1078
1093
  }
1079
1094
  pushed.push(imageKey);
1080
1095
  } catch (error) {
@@ -1111,7 +1126,7 @@ async function handleReprocess(request) {
1111
1126
  const originalPath = _path2.default.join(process.cwd(), "public", imageKey);
1112
1127
  try {
1113
1128
  buffer = await _fs.promises.readFile(originalPath);
1114
- } catch (e25) {
1129
+ } catch (e26) {
1115
1130
  if (isPushedToCloud) {
1116
1131
  buffer = await downloadFromCdn(imageKey);
1117
1132
  const dir = _path2.default.dirname(originalPath);
@@ -1128,7 +1143,7 @@ async function handleReprocess(request) {
1128
1143
  await deleteLocalThumbnails(imageKey);
1129
1144
  try {
1130
1145
  await _fs.promises.unlink(originalPath);
1131
- } catch (e26) {
1146
+ } catch (e27) {
1132
1147
  }
1133
1148
  }
1134
1149
  meta[imageKey] = updatedEntry;
@@ -1228,7 +1243,7 @@ async function handleProcessAllStream() {
1228
1243
  await deleteLocalThumbnails(key);
1229
1244
  try {
1230
1245
  await _fs.promises.unlink(fullPath);
1231
- } catch (e27) {
1246
+ } catch (e28) {
1232
1247
  }
1233
1248
  }
1234
1249
  processed.push(key.slice(1));
@@ -1267,13 +1282,13 @@ async function handleProcessAllStream() {
1267
1282
  }
1268
1283
  }
1269
1284
  }
1270
- } catch (e28) {
1285
+ } catch (e29) {
1271
1286
  }
1272
1287
  }
1273
1288
  const imagesDir = _path2.default.join(process.cwd(), "public", "images");
1274
1289
  try {
1275
1290
  await findOrphans(imagesDir);
1276
- } catch (e29) {
1291
+ } catch (e30) {
1277
1292
  }
1278
1293
  async function removeEmptyDirs(dir) {
1279
1294
  try {
@@ -1291,13 +1306,13 @@ async function handleProcessAllStream() {
1291
1306
  await _fs.promises.rmdir(dir);
1292
1307
  }
1293
1308
  return isEmpty;
1294
- } catch (e30) {
1309
+ } catch (e31) {
1295
1310
  return true;
1296
1311
  }
1297
1312
  }
1298
1313
  try {
1299
1314
  await removeEmptyDirs(imagesDir);
1300
- } catch (e31) {
1315
+ } catch (e32) {
1301
1316
  }
1302
1317
  await saveMeta(meta);
1303
1318
  sendEvent({
@@ -1360,7 +1375,7 @@ async function handleScanStream() {
1360
1375
  allFiles.push({ relativePath: relPath, fullPath });
1361
1376
  }
1362
1377
  }
1363
- } catch (e32) {
1378
+ } catch (e33) {
1364
1379
  }
1365
1380
  }
1366
1381
  const publicDir = _path2.default.join(process.cwd(), "public");
@@ -1420,7 +1435,7 @@ async function handleScanStream() {
1420
1435
  h: metadata.height || 0,
1421
1436
  b: blurhash
1422
1437
  };
1423
- } catch (e33) {
1438
+ } catch (e34) {
1424
1439
  meta[imageKey] = { w: 0, h: 0 };
1425
1440
  }
1426
1441
  }