mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-11-18 01:54:23 +01:00
merge: reconcile paid hosting with shared cache and main
This commit is contained in:
commit
e71e6b6389
39 files changed
+2313
-56
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import { cacheMetricsReport } from "../../core/cache-observability";
|
||||
import { sharedBlobCache, resultBlobCache } from "../../core/blob-cache";
|
||||
import { AsyncCache } from "../../core/async-cache";
|
||||
import * as os from "os";
|
||||
import { execFile } from "child_process";
|
||||
@@ -88,6 +90,15 @@ router.get("/performance", async (req, res) => {
|
||||
catch { res.json({ available: false, instances: [], routes: [], stages: [] }); }
|
||||
});
|
||||
|
||||
router.get("/cache", async (req, res) => {
|
||||
res.set("Cache-Control", "no-store");
|
||||
try {
|
||||
res.json({ ...cacheMetricsReport(Number(req.query.minutes)), enabled: config.SHARED_CACHE_ENABLED,
|
||||
filesystemSupported: config.STORAGE === "filesystem", source: sharedBlobCache()?.stats() || null,
|
||||
results: resultBlobCache()?.stats() || null });
|
||||
} catch { res.json({ available: false, reason: "The cache index is unavailable", rows: [] }); }
|
||||
});
|
||||
|
||||
function dashboardCache(
|
||||
_req: express.Request,
|
||||
res: express.Response,
|
||||
|
||||
@@ -146,7 +146,8 @@ router.get(
|
||||
anonymizedPath,
|
||||
repo.model.options
|
||||
);
|
||||
res.header("ETag", etag);
|
||||
if (config.SHARED_CACHE_ENABLED) res.vary("Accept-Encoding");
|
||||
res.header("ETag", config.SHARED_CACHE_ENABLED ? `W/${etag}` : etag);
|
||||
// Force the browser to revalidate every time. The previous 210-day
|
||||
// max-age was keyed only on the upstream sha, so editing the
|
||||
// anonymization term list left old anonymizations cached under the
|
||||
|
||||
@@ -162,7 +162,7 @@ router.post(
|
||||
repo.status == RepositoryStatus.PREPARING ||
|
||||
repo.status == RepositoryStatus.QUEUE ||
|
||||
(repo.status == RepositoryStatus.DOWNLOAD &&
|
||||
repo.model.statusDate > new Date(Date.now() - 5 * 60_000)) ||
|
||||
repo.statusActivityDate > new Date(Date.now() - 5 * 60_000)) ||
|
||||
repo.status == RepositoryStatus.REMOVING ||
|
||||
repo.status == RepositoryStatus.EXPIRING
|
||||
) {
|
||||
|
||||
@@ -324,7 +324,7 @@ router.get(
|
||||
if (repo.status != "ready") {
|
||||
if (
|
||||
repo.status != RepositoryStatus.QUEUE &&
|
||||
repo.model.statusDate < fiveMinuteAgo
|
||||
repo.statusActivityDate < fiveMinuteAgo
|
||||
) {
|
||||
await repo.updateStatus(RepositoryStatus.PREPARING);
|
||||
await downloadQueue.add(repo.repoId, { repoId: repo.repoId }, {
|
||||
|
||||
Reference in new issue
Block a user