Change function to const for internal helpers
This commit is contained in:
@ -1,24 +1,13 @@
|
||||
import { error } from "@sveltejs/kit";
|
||||
import StreamZip, { StreamZipAsync } from "node-stream-zip";
|
||||
|
||||
async function _getZip(zipName: string) {
|
||||
let zip = null;
|
||||
try {
|
||||
zip = new StreamZip.async({ file: `./zip/${zipName}` });
|
||||
} catch (err: any) {
|
||||
console.error(`${err.stack}`.replaceAll('/home/sveltekit', '.'));
|
||||
throw error(404, `Album not found.`);
|
||||
}
|
||||
return zip;
|
||||
}
|
||||
async function _getFile(zip: StreamZipAsync, entryName: string) {
|
||||
return await zip.entryData(entryName);
|
||||
}
|
||||
async function _getMetadata(zip: StreamZipAsync) {
|
||||
const _getZip = async (zipName: string) => new StreamZip.async({ file: `./zip/${zipName}` });
|
||||
const _getFile = async (zip: StreamZipAsync, entryName: string) => await zip.entryData(entryName);
|
||||
const _getMetadata = async (zip: StreamZipAsync) => {
|
||||
const metadataContent = await _getFile(zip, 'album.json');
|
||||
return JSON.parse(metadataContent.toString());
|
||||
}
|
||||
async function _close(zip: StreamZipAsync, keepOpen: boolean) {
|
||||
const _close = async (zip: StreamZipAsync, keepOpen: boolean) => {
|
||||
if (!keepOpen)
|
||||
await zip.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user