Merge pull request #123 from ente-io/fix-zip-upload
fix non google takeout zip upload
This commit is contained in:
commit
0e7ded20a3
|
@ -15,11 +15,12 @@ export const getSavedFilePaths = (type: FILE_PATH_TYPE) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function getZipEntryAsElectronFile(
|
export async function getZipEntryAsElectronFile(
|
||||||
|
zipName: string,
|
||||||
zip: StreamZip.StreamZipAsync,
|
zip: StreamZip.StreamZipAsync,
|
||||||
entry: StreamZip.ZipEntry
|
entry: StreamZip.ZipEntry
|
||||||
): Promise<ElectronFile> {
|
): Promise<ElectronFile> {
|
||||||
return {
|
return {
|
||||||
path: entry.name,
|
path: path.join(zipName, entry.name),
|
||||||
name: path.basename(entry.name),
|
name: path.basename(entry.name),
|
||||||
size: entry.size,
|
size: entry.size,
|
||||||
lastModified: entry.time,
|
lastModified: entry.time,
|
||||||
|
@ -58,6 +59,7 @@ export const getElectronFilesFromGoogleZip = async (filePath: string) => {
|
||||||
const zip = new StreamZip.async({
|
const zip = new StreamZip.async({
|
||||||
file: filePath,
|
file: filePath,
|
||||||
});
|
});
|
||||||
|
const zipName = path.basename(filePath, '.zip');
|
||||||
|
|
||||||
const entries = await zip.entries();
|
const entries = await zip.entries();
|
||||||
const files: ElectronFile[] = [];
|
const files: ElectronFile[] = [];
|
||||||
|
@ -65,7 +67,7 @@ export const getElectronFilesFromGoogleZip = async (filePath: string) => {
|
||||||
for (const entry of Object.values(entries)) {
|
for (const entry of Object.values(entries)) {
|
||||||
const basename = path.basename(entry.name);
|
const basename = path.basename(entry.name);
|
||||||
if (entry.isFile && basename.length > 0 && basename[0] !== '.') {
|
if (entry.isFile && basename.length > 0 && basename[0] !== '.') {
|
||||||
files.push(await getZipEntryAsElectronFile(zip, entry));
|
files.push(await getZipEntryAsElectronFile(zipName, zip, entry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue