Skip to content

Commit adbdced

Browse files
authored
Fix: Extract large RAR and ZIP files blocks the app for a while
1 parent 62a18dd commit adbdced

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

scripts/file-manager.js

+4-12
Original file line numberDiff line numberDiff line change
@@ -1188,8 +1188,6 @@ var fileCompressed = function(path, _realPath = false) {
11881188
let _this = this;
11891189
let only = this.config.only;
11901190

1191-
let promises = [];
1192-
11931191
for(let i = 0, len = zip.files.length; i < len; i++)
11941192
{
11951193
let entry = zip.files[i];
@@ -1216,20 +1214,18 @@ var fileCompressed = function(path, _realPath = false) {
12161214

12171215
this.setFileStatus(name, {extracted: true});
12181216

1219-
promises.push(new Promise(function(resolve, reject) {
1217+
await new Promise(function(resolve, reject) {
12201218
entry.stream().pipe(fs.createWriteStream(path)).on('error', reject).on('finish', function() {
12211219

12221220
_this.setProgress(_this.progressIndex++ / len);
12231221
_this.whenExtractFile(virtualPath);
12241222

12251223
resolve();
12261224
});
1227-
}));
1225+
});
12281226
}
12291227
}
12301228
}
1231-
1232-
await Promise.all(promises);
12331229
}
12341230
catch(error)
12351231
{
@@ -1429,8 +1425,6 @@ var fileCompressed = function(path, _realPath = false) {
14291425

14301426
if(!error)
14311427
{
1432-
let promises = [];
1433-
14341428
for(let i = 0, len = entries.length; i < len; i++)
14351429
{
14361430
let entry = entries[i];
@@ -1456,7 +1450,7 @@ var fileCompressed = function(path, _realPath = false) {
14561450

14571451
_this.setFileStatus(name, {extracted: true});
14581452

1459-
promises.push(new Promise(function(resolve, reject) {
1453+
await new Promise(function(resolve, reject) {
14601454
rar.stream(name).on('error', reject).on('end', function() {
14611455

14621456
_this.setProgress(_this.progressIndex++ / len);
@@ -1465,13 +1459,11 @@ var fileCompressed = function(path, _realPath = false) {
14651459
resolve();
14661460

14671461
}).pipe(fs.createWriteStream(path));
1468-
}));
1462+
});
14691463
}
14701464
}
14711465
}
14721466

1473-
await Promise.all(promises);
1474-
14751467
_this.setProgress(1);
14761468

14771469
console.timeEnd('extractRar');

0 commit comments

Comments
 (0)