Enable E-Tags for GUI and RAW
This commit is contained in:
@ -95,7 +95,7 @@ export async function getFile(
|
||||
pkgName: string,
|
||||
version: string | null | undefined,
|
||||
file: string
|
||||
): Promise<Uint8Array | null | undefined> {
|
||||
): Promise<{ etag: string; data: Uint8Array } | null | undefined> {
|
||||
const meta = await db.package.findOne({ name: pkgName });
|
||||
|
||||
if (!meta || meta.versions.length < 1) return null;
|
||||
@ -122,8 +122,12 @@ export async function getFile(
|
||||
console.log("Getting file from:", bucketPath);
|
||||
|
||||
try {
|
||||
const data = (await bucket.getObject(bucketPath))?.body;
|
||||
return data;
|
||||
const res = await bucket.getObject(bucketPath);
|
||||
if (!res) return undefined;
|
||||
return {
|
||||
etag: res.etag,
|
||||
data: res.body,
|
||||
};
|
||||
} catch (err) {
|
||||
const msg = err.message as string;
|
||||
if (msg.indexOf("404") >= 0) return null;
|
||||
|
Reference in New Issue
Block a user