Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(os): avoid tiny personalized ISO downloads from stale edge metadata

+56 -21
+56 -21
system/public/aesthetic.computer/disks/os.mjs
··· 1 1 // os, 2026.03.12 2 2 // FedAC OS — build list with commit messages; download your personalized copy. 3 3 4 - const OVEN = "https://oven-edge.aesthetic-computer.workers.dev"; 5 - const OVEN_WS = "wss://oven.aesthetic.computer/ws"; 6 - const ISO_BASE = OVEN + "/os/latest.iso"; 7 - function OVEN_BASE() { return OVEN; } 8 - function RELEASES_URL() { return OVEN + "/os-releases"; } 9 - function OVEN_IMAGE_URL() { return OVEN + "/os-image"; } 10 - function OVEN_WS_URL() { return OVEN_WS; } 4 + const OVEN = "https://oven-edge.aesthetic-computer.workers.dev"; 5 + const OVEN_WS = "wss://oven.aesthetic.computer/ws"; 6 + const OVEN_ORIGIN = "https://oven.aesthetic.computer"; 7 + const ISO_BASE = OVEN + "/os/latest.iso"; 8 + function OVEN_BASE() { return OVEN; } 9 + function RELEASES_URL() { return OVEN + "/os-releases"; } 10 + function OVEN_WS_URL() { return OVEN_WS; } 11 11 function templateIsoUrl() { 12 12 const base = ISO_BASE; 13 13 if (variantIdx === 0) return base; ··· 910 910 }); 911 911 } 912 912 913 - async function startDownload(needsPaint) { 913 + async function startDownload(needsPaint) { 914 914 downloading = true; 915 915 downloadProgress = 0; 916 916 downloadMB = 0; ··· 920 920 console.log("[os] Starting download:", osLabel(), "piece:", piece); 921 921 needsPaint(); 922 922 923 - try { 924 - const url = OVEN_IMAGE_URL() + "?piece=" + encodeURIComponent(piece) + "&wifi=" + (wifiEnabled ? "1" : "0") + (variantIdx === 1 ? "&variant=cl" : ""); 925 - console.log("[os] Fetching:", url); 926 - const res = await fetch(url, { 927 - headers: { Authorization: "Bearer " + token }, 928 - }); 929 - 930 - if (!res.ok) { 931 - const err = await res.json().catch(() => ({})); 932 - throw new Error(err.error || "Download failed: " + res.status); 933 - } 934 - 935 - const contentLength = parseInt(res.headers.get("content-length") || "0"); 923 + try { 924 + const query = "?piece=" + encodeURIComponent(piece) + "&wifi=" + (wifiEnabled ? "1" : "0") + (variantIdx === 1 ? "&variant=cl" : ""); 925 + const isoCandidates = [ 926 + OVEN_ORIGIN + "/os-image" + query, 927 + OVEN + "/os-image" + query, 928 + ]; 929 + const MIN_EXPECTED_ISO_BYTES = 100 * 1024 * 1024; 930 + 931 + let res = null; 932 + let usedUrl = ""; 933 + let lastErr = ""; 934 + for (const url of isoCandidates) { 935 + console.log("[os] Fetching:", url); 936 + let attempt; 937 + try { 938 + attempt = await fetch(url, { 939 + headers: { Authorization: "Bearer " + token }, 940 + }); 941 + } catch (err) { 942 + lastErr = err?.message || String(err); 943 + continue; 944 + } 945 + 946 + if (!attempt.ok) { 947 + const err = await attempt.json().catch(() => ({})); 948 + lastErr = err.error || ("Download failed: " + attempt.status); 949 + continue; 950 + } 951 + 952 + const len = parseInt(attempt.headers.get("content-length") || "0"); 953 + if (len > 0 && len < MIN_EXPECTED_ISO_BYTES) { 954 + console.warn("[os] Rejecting suspiciously small ISO response:", len, "bytes from", url); 955 + try { attempt.body?.cancel(); } catch (_) {} 956 + lastErr = "Received suspiciously small image (" + len + " bytes)"; 957 + continue; 958 + } 959 + 960 + res = attempt; 961 + usedUrl = url; 962 + break; 963 + } 964 + 965 + if (!res) { 966 + throw new Error(lastErr || "Download failed"); 967 + } 968 + console.log("[os] Download source:", usedUrl); 969 + 970 + const contentLength = parseInt(res.headers.get("content-length") || "0"); 936 971 downloadTotalMB = contentLength / 1048576; 937 972 downloadStatus = "downloading..."; 938 973 needsPaint();