@gallop.software/studio 2.2.5 → 2.2.7

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.
@@ -11,7 +11,7 @@
11
11
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
12
12
  }
13
13
  </style>
14
- <script type="module" crossorigin src="/assets/index-7rndMerw.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-Dqsov2mn.js"></script>
15
15
  </head>
16
16
  <body>
17
17
  <div id="root"></div>
@@ -2180,6 +2180,45 @@ async function handleCancelUpdates(request) {
2180
2180
  return jsonResponse({ error: "Failed to cancel updates" }, { status: 500 });
2181
2181
  }
2182
2182
  }
2183
+ async function handleClearCache(request) {
2184
+ const publicUrl = process.env.CLOUDFLARE_R2_PUBLIC_URL?.replace(/\/$/, "");
2185
+ try {
2186
+ const { paths } = await request.json();
2187
+ if (!paths || !Array.isArray(paths) || paths.length === 0) {
2188
+ return jsonResponse({ error: "No paths provided" }, { status: 400 });
2189
+ }
2190
+ const meta = await loadMeta();
2191
+ const cdnUrls = getCdnUrls(meta);
2192
+ const urlsToPurge = [];
2193
+ for (const itemPath of paths) {
2194
+ const key = itemPath.startsWith("public/") ? "/" + itemPath.slice(7) : itemPath;
2195
+ const entry = meta[key];
2196
+ if (!entry || entry.c === void 0) continue;
2197
+ const cdnUrl = cdnUrls[entry.c]?.replace(/\/$/, "");
2198
+ if (!cdnUrl) continue;
2199
+ urlsToPurge.push(`${cdnUrl}${key}`);
2200
+ if (entry.sm || entry.md || entry.lg || entry.f) {
2201
+ for (const thumbPath of getAllThumbnailPaths(key)) {
2202
+ urlsToPurge.push(`${cdnUrl}${thumbPath}`);
2203
+ }
2204
+ }
2205
+ }
2206
+ if (urlsToPurge.length === 0) {
2207
+ return jsonResponse({
2208
+ success: true,
2209
+ message: "No CDN files to clear cache for."
2210
+ });
2211
+ }
2212
+ const cacheResult = await purgeCloudflareCache(urlsToPurge);
2213
+ return jsonResponse({
2214
+ success: cacheResult.status === "success",
2215
+ message: cacheResult.message || `Cleared cache for ${urlsToPurge.length} URLs.`
2216
+ });
2217
+ } catch (error) {
2218
+ console.error("Clear cache error:", error);
2219
+ return jsonResponse({ error: "Failed to clear cache" }, { status: 500 });
2220
+ }
2221
+ }
2183
2222
 
2184
2223
  // src/handlers/scan.ts
2185
2224
  import { promises as fs8 } from "fs";
@@ -2749,6 +2788,7 @@ async function startServer(options) {
2749
2788
  app.post("/api/studio/download-stream", wrapHandler(handleDownloadStream, true));
2750
2789
  app.post("/api/studio/push-updates-stream", wrapHandler(handlePushUpdatesStream, true));
2751
2790
  app.post("/api/studio/cancel-updates", wrapHandler(handleCancelUpdates));
2791
+ app.post("/api/studio/clear-cache", wrapHandler(handleClearCache));
2752
2792
  app.post("/api/studio/scan", wrapHandler(handleScanStream, true));
2753
2793
  app.post("/api/studio/delete-orphans", wrapHandler(handleDeleteOrphans));
2754
2794
  app.post("/api/studio/import", wrapHandler(handleImportUrls, true));