From ebcf54d58e6ec02e6d7cf10ce6e288e5652d7266 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Tue, 20 Dec 2022 11:02:01 +0530 Subject: [PATCH] pass zip name as the base path as for zip files --- src/services/upload.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/services/upload.ts b/src/services/upload.ts index 8379df09d..38fa08995 100644 --- a/src/services/upload.ts +++ b/src/services/upload.ts @@ -15,11 +15,12 @@ export const getSavedFilePaths = (type: FILE_PATH_TYPE) => { }; export async function getZipEntryAsElectronFile( + zipName: string, zip: StreamZip.StreamZipAsync, entry: StreamZip.ZipEntry ): Promise { return { - path: entry.name, + path: path.join(zipName, entry.name), name: path.basename(entry.name), size: entry.size, lastModified: entry.time, @@ -58,6 +59,7 @@ export const getElectronFilesFromGoogleZip = async (filePath: string) => { const zip = new StreamZip.async({ file: filePath, }); + const zipName = path.basename(filePath, '.zip'); const entries = await zip.entries(); const files: ElectronFile[] = []; @@ -65,7 +67,7 @@ export const getElectronFilesFromGoogleZip = async (filePath: string) => { for (const entry of Object.values(entries)) { const basename = path.basename(entry.name); if (entry.isFile && basename.length > 0 && basename[0] !== '.') { - files.push(await getZipEntryAsElectronFile(zip, entry)); + files.push(await getZipEntryAsElectronFile(zipName, zip, entry)); } }