mirror of
https://github.com/HeyPuter/puter.git
synced 2025-01-26 09:18:48 +08:00
redirected unzip to helper method
This commit is contained in:
parent
a9bebdd7f0
commit
a93236118f
@ -1200,24 +1200,8 @@ function UIItem(options){
|
|||||||
menu_items.push({
|
menu_items.push({
|
||||||
html: i18n('unzip'),
|
html: i18n('unzip'),
|
||||||
onClick: async function(){
|
onClick: async function(){
|
||||||
const zip = new JSZip();
|
|
||||||
let filePath = $(el_item).attr('data-path');
|
let filePath = $(el_item).attr('data-path');
|
||||||
let file = puter.fs.read($(el_item).attr('data-path'));
|
window.unzipItem(filePath)
|
||||||
|
|
||||||
zip.loadAsync(file).then(async function (zip) {
|
|
||||||
const rootdir = await puter.fs.mkdir(path.dirname(filePath) + '/' + path.basename(filePath, '.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);
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user