Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/zip operation #787

Merged
merged 33 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
01aaa07
added zip progress counter configurations
4nshuman Oct 5, 2024
1929aaf
added fflate on libPath on puter-gui
4nshuman Oct 5, 2024
4c7b75e
added fflate on static asset and libPath
4nshuman Oct 5, 2024
f3625ed
added terms for status message on zip operation
4nshuman Oct 5, 2024
582c411
added fflate min js to the library
4nshuman Oct 5, 2024
f05f745
added helper method to convert binary large object to uInt8Array for …
4nshuman Oct 5, 2024
dfe71d5
modified zipping operationand integrated fflate
4nshuman Oct 5, 2024
a9bebdd
fixed typo
4nshuman Oct 6, 2024
a932361
redirected unzip to helper method
4nshuman Oct 6, 2024
deb8c4e
added status message terms
4nshuman Oct 6, 2024
f6541fc
convention implemented definition header
4nshuman Oct 6, 2024
09d10cb
rectified progress window for unzip operation
4nshuman Oct 6, 2024
5b477c2
fixed module name
4nshuman Oct 6, 2024
b9b8229
fixed comments phrasing
4nshuman Oct 6, 2024
b9d7a1d
added zip support for empty directories
4nshuman Oct 6, 2024
00f2dbd
added window hide delay config
4nshuman Oct 6, 2024
9a2e701
eleminate JSZip invocation
4nshuman Oct 6, 2024
e5f0f46
added blob to uInt8Array conversion
4nshuman Oct 6, 2024
a79cc04
implemented fflate unzip operation
4nshuman Oct 6, 2024
2a82579
added unzip error handler
4nshuman Oct 6, 2024
e992e4d
unzipped directory creation
4nshuman Oct 6, 2024
a09dd29
added empty directory check and file creation
4nshuman Oct 6, 2024
f0f8e45
added Promises to handle multiple file creation and closing progress …
4nshuman Oct 6, 2024
e252567
Added progress dialog details
4nshuman Oct 6, 2024
822d850
purge JSZip
4nshuman Oct 6, 2024
857c3b8
added fflate to lint check
4nshuman Oct 6, 2024
d39b7a8
record unique directory list
4nshuman Oct 19, 2024
fc461c8
added absolute file path processing
4nshuman Oct 19, 2024
f32b1cf
added option to create parent directories for programmatic file drops
4nshuman Oct 19, 2024
4fdea7d
offloaded write operations to Upload module
4nshuman Oct 19, 2024
a646b02
provide incremental directories to mkdir
4nshuman Oct 19, 2024
fabc21e
fixed sorting logic on directory list
4nshuman Oct 19, 2024
63b4da5
connected upload's inbuilt progress counter
4nshuman Oct 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default [
"iro": true, // iro.js color picker
"$": true, // jQuery
"jQuery": true, // jQuery
"JSZip": true, // JSZip
"fflate": true, // fflate
"_": true, // lodash
"QRCode": true, // qrcode
"io": true, // socket.io
Expand Down
2 changes: 1 addition & 1 deletion src/gui/puter-gui.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"/lib/timeago.min.js",
"/lib/iro.min.js",
"/lib/isMobile.min.js",
"/lib/jszip-3.10.1.min.js"
"/lib/fflate-0.8.2.min.js"
],
"css_paths": [
"/css/normalize.css",
Expand Down
20 changes: 2 additions & 18 deletions src/gui/src/UI/UIItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -1200,24 +1200,8 @@ function UIItem(options){
menu_items.push({
html: i18n('unzip'),
onClick: async function(){
const zip = new JSZip();
let filPath = $(el_item).attr('data-path');
let file = puter.fs.read($(el_item).attr('data-path'));

zip.loadAsync(file).then(async function (zip) {
const rootdir = await puter.fs.mkdir(path.dirname(filPath) + '/' + path.basename(filPath, '.zip'), {dedupeName: true});
Object.keys(zip.files).forEach(async function (filename) {
if(filename.endsWith('/'))
await puter.fs.mkdir(rootdir.path +'/' + filename, {createMissingParents: true});
zip.files[filename].async('blob').then(async function (fileData) {
await puter.fs.write(rootdir.path +'/' + filename, fileData);
}).catch(function (e) {
// UIAlert(e.message);
})
})
}).catch(function (e) {
// UIAlert(e.message);
})
let filePath = $(el_item).attr('data-path');
window.unzipItem(filePath)
}
})
}
Expand Down
13 changes: 13 additions & 0 deletions src/gui/src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ window.taskbar_height = window.default_taskbar_height;
window.upload_progress_hide_delay = 500;
window.active_uploads = {};
window.copy_progress_hide_delay = 1000;
window.zip_progress_hide_delay = 2000;
window.unzip_progress_hide_delay = 2000;
window.busy_indicator_hide_delay = 600;
window.global_element_id = 0;
window.operation_id = 0;
Expand All @@ -126,6 +128,17 @@ window.watchItems = [];
window.appdata_signatures = {};
window.appCallbackFunctions = [];

// Defines how much weight each operation has in the zipping progress
window.zippingProgressConfig = {
TOTAL: 100
}
//Assuming uInt8Array conversion a file takes betwneen 45% to 60% of the total progress
window.zippingProgressConfig.SEQUENCING = Math.floor(Math.random() * (60 - 45 + 1)) + 45,
//Assuming zipping up uInt8Arrays takes betwneen 20% to 23% of the total progress
window.zippingProgressConfig.ZIPPING = Math.floor(Math.random() * (23 - 20 + 1)) + 20,
//Assuming writing a zip file takes betwneen 10% to 14% of the total progress
window.zippingProgressConfig.WRITING = Math.floor(Math.random() * (14 - 10 + 1)) + 14,

// 'Launch' apps
window.launch_apps = [];
window.launch_apps.recent = []
Expand Down
Loading