|
|
@@ -97,11 +97,12 @@ class GrowiBridgeService {
|
|
|
* @return {object} meta{object} and files{Array.<object>}
|
|
|
*/
|
|
|
async parseZipFile(zipFile) {
|
|
|
- const readStream = fs.createReadStream(zipFile);
|
|
|
- const unzipStream = readStream.pipe(unzipper.Parse());
|
|
|
const fileStats = [];
|
|
|
let meta = {};
|
|
|
|
|
|
+ const readStream = fs.createReadStream(zipFile);
|
|
|
+ const unzipStream = readStream.pipe(unzipper.Parse());
|
|
|
+
|
|
|
unzipStream.on('entry', async(entry) => {
|
|
|
const fileName = entry.path;
|
|
|
const size = entry.vars.uncompressedSize; // There is also compressedSize;
|
|
|
@@ -120,7 +121,14 @@ class GrowiBridgeService {
|
|
|
entry.autodrain();
|
|
|
});
|
|
|
|
|
|
- await streamToPromise(unzipStream);
|
|
|
+ try {
|
|
|
+ await streamToPromise(unzipStream);
|
|
|
+ }
|
|
|
+ // if zip is broken
|
|
|
+ catch (err) {
|
|
|
+ logger.error(err);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
return {
|
|
|
meta,
|