@gallop.software/studio 1.4.2 → 1.4.4

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.
@@ -1432,7 +1432,8 @@ async function handleUnprocessStream(request) {
1432
1432
  try {
1433
1433
  const meta = await loadMeta();
1434
1434
  const cdnUrls = getCdnUrls(meta);
1435
- const unprocessed = [];
1435
+ const removed = [];
1436
+ const skipped = [];
1436
1437
  const errors = [];
1437
1438
  const urlsToPurge = [];
1438
1439
  const total = imageKeys.length;
@@ -1455,6 +1456,11 @@ async function handleUnprocessStream(request) {
1455
1456
  errors.push(imageKey);
1456
1457
  continue;
1457
1458
  }
1459
+ const hasThumbnails = entry.sm || entry.md || entry.lg || entry.f;
1460
+ if (!hasThumbnails) {
1461
+ skipped.push(imageKey);
1462
+ continue;
1463
+ }
1458
1464
  const existingCdnIndex = entry.c;
1459
1465
  const existingCdnUrl = existingCdnIndex !== void 0 ? cdnUrls[existingCdnIndex] : void 0;
1460
1466
  const isInOurR2 = existingCdnUrl === publicUrl;
@@ -1470,7 +1476,7 @@ async function handleUnprocessStream(request) {
1470
1476
  b: entry.b,
1471
1477
  ...entry.c !== void 0 ? { c: entry.c } : {}
1472
1478
  };
1473
- unprocessed.push(imageKey);
1479
+ removed.push(imageKey);
1474
1480
  } catch (error) {
1475
1481
  console.error(`Failed to unprocess ${imageKey}:`, error);
1476
1482
  errors.push(imageKey);
@@ -1482,11 +1488,19 @@ async function handleUnprocessStream(request) {
1482
1488
  sendEvent({ type: "cleanup", message: "Purging CDN cache..." });
1483
1489
  await purgeCloudflareCache(urlsToPurge);
1484
1490
  }
1491
+ let message = `Removed thumbnails from ${removed.length} image${removed.length !== 1 ? "s" : ""}.`;
1492
+ if (skipped.length > 0) {
1493
+ message += ` ${skipped.length} image${skipped.length !== 1 ? "s" : ""} had no thumbnails.`;
1494
+ }
1495
+ if (errors.length > 0) {
1496
+ message += ` ${errors.length} image${errors.length !== 1 ? "s" : ""} failed.`;
1497
+ }
1485
1498
  sendEvent({
1486
1499
  type: "complete",
1487
- processed: unprocessed.length,
1500
+ processed: removed.length,
1501
+ skipped: skipped.length,
1488
1502
  errors: errors.length,
1489
- message: `Removed thumbnails from ${unprocessed.length} image${unprocessed.length !== 1 ? "s" : ""}${errors.length > 0 ? `, ${errors.length} error${errors.length !== 1 ? "s" : ""}` : ""}`
1503
+ message
1490
1504
  });
1491
1505
  controller.close();
1492
1506
  } catch (error) {
@@ -1616,16 +1630,20 @@ async function handleReprocessStream(request) {
1616
1630
  sendEvent({ type: "cleanup", message: "Purging CDN cache..." });
1617
1631
  await purgeCloudflareCache(urlsToPurge);
1618
1632
  }
1633
+ let message = `Generated thumbnails for ${processed.length} image${processed.length !== 1 ? "s" : ""}.`;
1634
+ if (errors.length > 0) {
1635
+ message += ` ${errors.length} image${errors.length !== 1 ? "s" : ""} failed.`;
1636
+ }
1619
1637
  sendEvent({
1620
1638
  type: "complete",
1621
1639
  processed: processed.length,
1622
1640
  errors: errors.length,
1623
- message: `Processed ${processed.length} image${processed.length !== 1 ? "s" : ""}${errors.length > 0 ? `, ${errors.length} error${errors.length !== 1 ? "s" : ""}` : ""}`
1641
+ message
1624
1642
  });
1625
1643
  controller.close();
1626
1644
  } catch (error) {
1627
1645
  console.error("Reprocess stream error:", error);
1628
- sendEvent({ type: "error", message: "Failed to process images" });
1646
+ sendEvent({ type: "error", message: "Failed to generate thumbnails" });
1629
1647
  controller.close();
1630
1648
  }
1631
1649
  }