entries
This commit is contained in:
parent
7ad4069b99
commit
5f0103682b
|
@ -18,7 +18,7 @@ import type { Electron, ZipItem } from "@/next/types/ipc";
|
||||||
* To avoid accidentally invoking it in a non-desktop app context, it requires
|
* To avoid accidentally invoking it in a non-desktop app context, it requires
|
||||||
* the {@link Electron} object as a parameter (even though it doesn't use it).
|
* the {@link Electron} object as a parameter (even though it doesn't use it).
|
||||||
*
|
*
|
||||||
* @param pathOrZipEntry Either the path on the file on the user's local file
|
* @param pathOrZipItem Either the path on the file on the user's local file
|
||||||
* system whose contents we want to stream. Or a tuple containing the path to a
|
* system whose contents we want to stream. Or a tuple containing the path to a
|
||||||
* zip file and the name of the entry within it.
|
* zip file and the name of the entry within it.
|
||||||
*
|
*
|
||||||
|
@ -35,20 +35,18 @@ import type { Electron, ZipItem } from "@/next/types/ipc";
|
||||||
*/
|
*/
|
||||||
export const readStream = async (
|
export const readStream = async (
|
||||||
_: Electron,
|
_: Electron,
|
||||||
pathOrZipEntry: string | ZipItem,
|
pathOrZipItem: string | ZipItem,
|
||||||
): Promise<{ response: Response; size: number; lastModifiedMs: number }> => {
|
): Promise<{ response: Response; size: number; lastModifiedMs: number }> => {
|
||||||
let url: URL;
|
let url: URL;
|
||||||
if (typeof pathOrZipEntry == "string") {
|
if (typeof pathOrZipItem == "string") {
|
||||||
url = new URL(`stream://read${pathOrZipEntry}`);
|
url = new URL(`stream://read${pathOrZipItem}`);
|
||||||
} else {
|
} else {
|
||||||
const [zipPath, entryName] = pathOrZipEntry;
|
const [zipPath, entryName] = pathOrZipItem;
|
||||||
url = new URL(`stream://read${zipPath}`);
|
url = new URL(`stream://read${zipPath}`);
|
||||||
url.hash = entryName;
|
url.hash = entryName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const req = new Request(url, {
|
const req = new Request(url, { method: "GET" });
|
||||||
method: "GET",
|
|
||||||
});
|
|
||||||
|
|
||||||
const res = await fetch(req);
|
const res = await fetch(req);
|
||||||
if (!res.ok)
|
if (!res.ok)
|
||||||
|
|
Loading…
Reference in a new issue