fix
This commit is contained in:
parent
52db89e05b
commit
078f89dcb4
|
|
@ -43,30 +43,6 @@ export const _ = {
|
||||||
const path = dir.data(`/code/${site_id}/site/typings.d.ts`);
|
const path = dir.data(`/code/${site_id}/site/typings.d.ts`);
|
||||||
const file = Bun.file(path);
|
const file = Bun.file(path);
|
||||||
if (await file.exists()) {
|
if (await file.exists()) {
|
||||||
// const glob = new Glob("type_def*");
|
|
||||||
// for await (const item of glob.scan(
|
|
||||||
// dir.data(`/code/${site_id}/site`)
|
|
||||||
// )) {
|
|
||||||
// const stamp = parseInt(item.split(".")[1]);
|
|
||||||
// if (file.lastModified !== stamp) {
|
|
||||||
// await removeAsync(dir.data(`/code/${site_id}/site/${item}`));
|
|
||||||
// } else {
|
|
||||||
// return new Response(
|
|
||||||
// Bun.gzipSync(
|
|
||||||
// await Bun.file(
|
|
||||||
// dir.data(`/code/${site_id}/site/${item}`)
|
|
||||||
// ).arrayBuffer()
|
|
||||||
// ),
|
|
||||||
// {
|
|
||||||
// headers: {
|
|
||||||
// "content-type": "application/json",
|
|
||||||
// "content-encoding": "gzip",
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = JSON.stringify(await parseTypeDef(path));
|
const res = JSON.stringify(await parseTypeDef(path));
|
||||||
await Bun.write(
|
await Bun.write(
|
||||||
|
|
@ -114,6 +90,24 @@ export const _ = {
|
||||||
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[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 {
|
||||||
let file = Bun.file(build_path);
|
let file = Bun.file(build_path);
|
||||||
|
|
||||||
if (!(await file.exists())) {
|
if (!(await file.exists())) {
|
||||||
|
|
@ -141,7 +135,8 @@ export const _ = {
|
||||||
(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)
|
g.code_index_cache[site_id][build_path].ts !== ts)
|
||||||
) {
|
) {
|
||||||
if (!g.code_index_compressing) g.code_index_compressing = new Set();
|
if (!g.code_index_compressing)
|
||||||
|
g.code_index_compressing = new Set();
|
||||||
|
|
||||||
const key = `${site_id}-${build_path}`;
|
const key = `${site_id}-${build_path}`;
|
||||||
if (!g.code_index_compressing.has(key)) {
|
if (!g.code_index_compressing.has(key)) {
|
||||||
|
|
@ -162,22 +157,6 @@ export const _ = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Response(
|
return new Response(
|
||||||
await gzipAsync(new Uint8Array(await file.arrayBuffer())),
|
await gzipAsync(new Uint8Array(await file.arrayBuffer())),
|
||||||
{
|
{
|
||||||
|
|
@ -187,6 +166,9 @@ export const _ = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
} catch (e) {
|
||||||
|
return new Response("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "route": {
|
case "route": {
|
||||||
if (!g.route_cache) g.route_cache = {};
|
if (!g.route_cache) g.route_cache = {};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue