From e252567c889616435863e5e16f3f7c57ba5bb189 Mon Sep 17 00:00:00 2001 From: 4nshuman Date: Sun, 6 Oct 2024 21:19:42 +0530 Subject: [PATCH] Added progress dialog details --- src/gui/src/helpers.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/src/helpers.js b/src/gui/src/helpers.js index 97a6a091..5bc34b82 100644 --- a/src/gui/src/helpers.js +++ b/src/gui/src/helpers.js @@ -2184,9 +2184,16 @@ window.unzipItem = async function(itemPath) { }, 500); let filePath = itemPath; + let currentProgress = window.zippingProgressConfig.SEQUENCING; + progwin?.set_status(i18n('sequencing', path.basename(filePath))); let file = await blobToUint8Array(await puter.fs.read(filePath)); + progwin?.set_progress(currentProgress.toPrecision(2)); + + progwin?.set_status(i18n('unzipping', path.basename(filePath))); terminateOp = fflate.unzip(file, async (err, unzipped) => { + currentProgress += window.zippingProgressConfig.ZIPPING; + progwin?.set_progress(currentProgress.toPrecision(2)); if(err) { UIAlert(e.message); // close progress window @@ -2197,6 +2204,7 @@ window.unzipItem = async function(itemPath) { } else { const rootdir = await puter.fs.mkdir(path.dirname(filePath) + '/' + path.basename(filePath, '.zip'), { dedupeName: true }); let queuedFileWrites = [] + let perItemProgress = window.zippingProgressConfig.WRITING / Object.keys(unzipped).length; Object.keys(unzipped).forEach(fileItem => { let fileWriteProcess = new Promise(async (resolve, reject) => { try { @@ -2204,11 +2212,14 @@ window.unzipItem = async function(itemPath) { let fileData = new Blob([new Uint8Array(unzipped[fileItem], unzipped[fileItem].byteOffset, unzipped[fileItem].length)]); if (fileItem.includes("/")) { [dirLevel, fileName] = [fileItem.slice(0, fileItem.lastIndexOf("/")), fileItem.slice(fileItem.lastIndexOf("/") + 1)] - // await puter.fs.mkdir(rootdir.path + '/' + dirLevel, { createMissingParents: true }); + await puter.fs.mkdir(rootdir.path + '/' + dirLevel, { createMissingParents: true }); } else { fileName = fileItem; } + progwin?.set_status(i18n('writing', fileItem)); fileName != "" && await puter.fs.write(rootdir.path + '/' + fileItem, fileData); + currentProgress += perItemProgress; + progwin?.set_progress(currentProgress.toPrecision(2)); resolve(); } catch (e) { UIAlert(e.message); @@ -2218,6 +2229,7 @@ window.unzipItem = async function(itemPath) { queuedFileWrites.push(fileWriteProcess); }); Promise.all(queuedFileWrites).then(() => { + progwin?.set_progress(window.zippingProgressConfig.TOTAL.toPrecision(2)); // close progress window clearTimeout(progwin_timeout); setTimeout(() => {