下载优化
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
cbd860a35e
commit
52bb39d6c2
|
|
@ -14,6 +14,7 @@ function zipFiles(zipName, files) {
|
|||
let zipFileOutputStream = streamSaver.createWriteStream(zipName);
|
||||
// 创建下载文件流
|
||||
const fileIterator = files.values();
|
||||
let Url = null;
|
||||
let readableZipStream = new ZIP({
|
||||
async pull(ctrl) {
|
||||
const fileInfo = fileIterator.next();
|
||||
|
|
@ -23,6 +24,7 @@ function zipFiles(zipName, files) {
|
|||
let { name, url, IsEncapsulated = false } = fileInfo.value;
|
||||
if (IsEncapsulated) {
|
||||
url = await downloadFileToUrl(url)
|
||||
Url = url
|
||||
}
|
||||
// url = decodeUtf8(url); // 待定,可能做过特殊处理
|
||||
return fetch(url).then(res => {
|
||||
|
|
@ -43,14 +45,28 @@ function zipFiles(zipName, files) {
|
|||
store.dispatch('trials/setUnLock', false)
|
||||
readableZipStream = null;
|
||||
zipFileOutputStream = null;
|
||||
if (Url) {
|
||||
URL.revokeObjectURL(Url)
|
||||
Url = null
|
||||
}
|
||||
resolve(true)
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
readableZipStream = null;
|
||||
zipFileOutputStream = null;
|
||||
if (Url) {
|
||||
URL.revokeObjectURL(Url)
|
||||
Url = null
|
||||
}
|
||||
resolve(false)
|
||||
});
|
||||
} else {
|
||||
readableZipStream = null;
|
||||
zipFileOutputStream = null;
|
||||
if (Url) {
|
||||
URL.revokeObjectURL(Url)
|
||||
Url = null
|
||||
}
|
||||
resolve(false)
|
||||
}
|
||||
} catch (err) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue