rebuild
This commit is contained in:
parent
4ecc332717
commit
e6dac3d767
|
|
@ -86,56 +86,54 @@ export const _ = {
|
||||||
}
|
}
|
||||||
return new Response("");
|
return new Response("");
|
||||||
}
|
}
|
||||||
case "code": {
|
case "code": {
|
||||||
const arr = pathname.split("/").slice(2);
|
const arr = pathname.split("/").slice(2);
|
||||||
const codepath = arr.join("/");
|
const codepath = arr.join("/");
|
||||||
const build_path = code.path(site_id, "site", "build", codepath);
|
const build_path = code.path(site_id, "site", "build", codepath);
|
||||||
|
|
||||||
if (
|
|
||||||
g.code_index_cache &&
|
|
||||||
g.code_index_cache[site_id] &&
|
|
||||||
g.code_index_cache[site_id][build_path] &&
|
|
||||||
g.code_index_cache[site_id][build_path].content
|
|
||||||
) {
|
|
||||||
return new Response(
|
|
||||||
g.code_index_cache[site_id][build_path].content,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"content-encoding": "br",
|
|
||||||
"content-type": g.code_index_cache[site_id][build_path].type,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let file = Bun.file(build_path);
|
let file = Bun.file(build_path);
|
||||||
|
const ts = file.lastModified;
|
||||||
if (!(await file.exists())) {
|
if (
|
||||||
const root = `/code/${site_id}/site/src`;
|
g.code_index_cache &&
|
||||||
await ensureLib(root, site_id);
|
g.code_index_cache[site_id] &&
|
||||||
await ensureFiles(root, site_id);
|
g.code_index_cache[site_id][build_path] &&
|
||||||
await initFrontEnd(root, site_id);
|
g.code_index_cache[site_id][build_path].content &&
|
||||||
await new Promise<void>((resolve) => {
|
g.code_index_cache[site_id][build_path] &&
|
||||||
const ival = setInterval(async () => {
|
g.code_index_cache[site_id][build_path].ts === ts
|
||||||
file = Bun.file(build_path);
|
) {
|
||||||
const exists = await file.exists();
|
return new Response(
|
||||||
if (exists) {
|
g.code_index_cache[site_id][build_path].content,
|
||||||
clearInterval(ival);
|
{
|
||||||
resolve();
|
headers: {
|
||||||
}
|
"content-encoding": "br",
|
||||||
}, 100);
|
"content-type":
|
||||||
});
|
g.code_index_cache[site_id][build_path].type,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ts = file.lastModified;
|
// if (!(await file.exists())) {
|
||||||
|
// const root = `/code/${site_id}/site/src`;
|
||||||
|
// await ensureLib(root, site_id);
|
||||||
|
// await ensureFiles(root, site_id);
|
||||||
|
// await initFrontEnd(root, site_id);
|
||||||
|
// await new Promise<void>((resolve) => {
|
||||||
|
// const ival = setInterval(async () => {
|
||||||
|
// file = Bun.file(build_path);
|
||||||
|
// const exists = await file.exists();
|
||||||
|
// if (exists) {
|
||||||
|
// clearInterval(ival);
|
||||||
|
// resolve();
|
||||||
|
// }
|
||||||
|
// }, 100);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
if (!g.code_index_cache) g.code_index_cache = {};
|
if (!g.code_index_cache) g.code_index_cache = {};
|
||||||
if (!g.code_index_cache[site_id]) g.code_index_cache[site_id] = {};
|
if (!g.code_index_cache[site_id]) g.code_index_cache[site_id] = {};
|
||||||
if (
|
if (!g.code_index_cache[site_id][build_path]) {
|
||||||
!g.code_index_cache[site_id][build_path] ||
|
|
||||||
(g.code_index_cache[site_id][build_path] &&
|
|
||||||
g.code_index_cache[site_id][build_path].ts !== ts)
|
|
||||||
) {
|
|
||||||
if (!g.code_index_compressing)
|
if (!g.code_index_compressing)
|
||||||
g.code_index_compressing = new Set();
|
g.code_index_compressing = new Set();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue