strict 3
This commit is contained in:
parent
bee2cd533c
commit
0c312c0ea1
4 changed files with 12 additions and 10 deletions
|
@ -35,6 +35,10 @@ export const pathOrZipItemSize = async (
|
|||
const [zipPath, entryName] = pathOrZipItem;
|
||||
const zip = new StreamZip.async({ file: zipPath });
|
||||
const entry = await zip.entry(entryName);
|
||||
if (!entry)
|
||||
throw new Error(
|
||||
`An entry with name ${entryName} does not exist in the zip file at ${zipPath}`,
|
||||
);
|
||||
const size = entry.size;
|
||||
zip.close();
|
||||
return size;
|
||||
|
@ -60,7 +64,7 @@ export const pendingUploads = async (): Promise<PendingUploads | undefined> => {
|
|||
// file, but the dedup logic will kick in at that point so no harm will come
|
||||
// off it.
|
||||
if (allZipItems === undefined) {
|
||||
const allZipPaths = uploadStatusStore.get("filePaths");
|
||||
const allZipPaths = uploadStatusStore.get("filePaths") ?? [];
|
||||
const zipPaths = allZipPaths.filter((f) => existsSync(f));
|
||||
zipItems = [];
|
||||
for (const zip of zipPaths)
|
||||
|
@ -83,7 +87,7 @@ export const setPendingUploads = async (pendingUploads: PendingUploads) =>
|
|||
|
||||
export const markUploadedFiles = async (paths: string[]) => {
|
||||
const existing = uploadStatusStore.get("filePaths");
|
||||
const updated = existing.filter((p) => !paths.includes(p));
|
||||
const updated = existing?.filter((p) => !paths.includes(p));
|
||||
uploadStatusStore.set("filePaths", updated);
|
||||
};
|
||||
|
||||
|
@ -91,7 +95,7 @@ export const markUploadedZipItems = async (
|
|||
items: [zipPath: string, entryName: string][],
|
||||
) => {
|
||||
const existing = uploadStatusStore.get("zipItems");
|
||||
const updated = existing.filter(
|
||||
const updated = existing?.filter(
|
||||
(z) => !items.some((e) => z[0] == e[0] && z[1] == e[1]),
|
||||
);
|
||||
uploadStatusStore.set("zipItems", updated);
|
||||
|
|
|
@ -28,7 +28,7 @@ export interface FolderWatchSyncedFile {
|
|||
export type ZipItem = [zipPath: string, entryName: string];
|
||||
|
||||
export interface PendingUploads {
|
||||
collectionName: string;
|
||||
collectionName?: string;
|
||||
filePaths: string[];
|
||||
zipItems: ZipItem[];
|
||||
}
|
||||
|
|
|
@ -930,9 +930,5 @@ export const setPendingUploads = async (
|
|||
}
|
||||
}
|
||||
|
||||
await electron.setPendingUploads({
|
||||
collectionName,
|
||||
filePaths,
|
||||
zipItems: zipItems,
|
||||
});
|
||||
await electron.setPendingUploads({ collectionName, filePaths, zipItems });
|
||||
};
|
||||
|
|
|
@ -650,8 +650,10 @@ export interface PendingUploads {
|
|||
* This is name of the collection (when uploading to a singular collection)
|
||||
* or the root collection (when uploading to separate * albums) to which we
|
||||
* these uploads are meant to go to. See {@link CollectionMapping}.
|
||||
*
|
||||
* It will not be set if we're just uploading standalone files.
|
||||
*/
|
||||
collectionName: string;
|
||||
collectionName?: string;
|
||||
/**
|
||||
* Paths of regular files that need to be uploaded.
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue