@gallop.software/studio 1.5.1 → 1.5.3

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.
@@ -2,7 +2,7 @@ import {
2
2
  getAllThumbnailPaths,
3
3
  getThumbnailPath,
4
4
  isProcessed
5
- } from "../chunk-VQJAJVAQ.mjs";
5
+ } from "../chunk-TRYWHLJ2.mjs";
6
6
 
7
7
  // src/handlers/index.ts
8
8
  import { NextResponse as NextResponse6 } from "next/server";
@@ -343,6 +343,26 @@ function getExistingThumbnails(originalPath, entry) {
343
343
  }
344
344
  return thumbnails;
345
345
  }
346
+ function countFileTypes(folderPrefix, fileEntries, cdnUrls, r2PublicUrl) {
347
+ let cloudCount = 0;
348
+ let remoteCount = 0;
349
+ let localCount = 0;
350
+ for (const [key, entry] of fileEntries) {
351
+ if (key.startsWith(folderPrefix)) {
352
+ if (entry.c !== void 0) {
353
+ const cdnUrl = cdnUrls[entry.c];
354
+ if (cdnUrl === r2PublicUrl) {
355
+ cloudCount++;
356
+ } else {
357
+ remoteCount++;
358
+ }
359
+ } else {
360
+ localCount++;
361
+ }
362
+ }
363
+ }
364
+ return { cloudCount, remoteCount, localCount };
365
+ }
346
366
  async function handleList(request) {
347
367
  const searchParams = request.nextUrl.searchParams;
348
368
  const requestedPath = searchParams.get("path") || "public";
@@ -462,6 +482,9 @@ async function handleList(request) {
462
482
  const isImagesFolder = entry.name === "images" && !relativePath;
463
483
  const folderPath = relativePath ? `public/${relativePath}/${entry.name}` : `public/${entry.name}`;
464
484
  let fileCount = 0;
485
+ let cloudCount = 0;
486
+ let remoteCount = 0;
487
+ let localCount = 0;
465
488
  if (isImagesFolder) {
466
489
  for (const [key, metaEntry] of fileEntries) {
467
490
  if (isProcessed(metaEntry)) {
@@ -473,12 +496,19 @@ async function handleList(request) {
473
496
  for (const k of metaKeys) {
474
497
  if (k.startsWith(folderPrefix)) fileCount++;
475
498
  }
499
+ const counts = countFileTypes(folderPrefix, fileEntries, cdnUrls, r2PublicUrl);
500
+ cloudCount = counts.cloudCount;
501
+ remoteCount = counts.remoteCount;
502
+ localCount = counts.localCount;
476
503
  }
477
504
  items.push({
478
505
  name: entry.name,
479
506
  path: folderPath,
480
507
  type: "folder",
481
508
  fileCount,
509
+ cloudCount,
510
+ remoteCount,
511
+ localCount,
482
512
  isProtected: isImagesFolder
483
513
  });
484
514
  }
@@ -521,11 +551,15 @@ async function handleList(request) {
521
551
  for (const k of metaKeys) {
522
552
  if (k.startsWith(folderPrefix)) fileCount++;
523
553
  }
554
+ const counts = countFileTypes(folderPrefix, fileEntries, cdnUrls, r2PublicUrl);
524
555
  items.push({
525
556
  name: folderName,
526
557
  path: relativePath ? `public/${relativePath}/${folderName}` : `public/${folderName}`,
527
558
  type: "folder",
528
559
  fileCount,
560
+ cloudCount: counts.cloudCount,
561
+ remoteCount: counts.remoteCount,
562
+ localCount: counts.localCount,
529
563
  isProtected: isInsideImagesFolder
530
564
  });
531
565
  }