浏览代码

Added progress dialog details

4nshuman 7 月之前
父节点
当前提交
e252567c88
共有 1 个文件被更改,包括 13 次插入1 次删除
  1. 13 1
      src/gui/src/helpers.js

+ 13 - 1
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(() => {