diff --git a/build/main.js b/build/main.js index 95e8fb2..c209cd9 100644 --- a/build/main.js +++ b/build/main.js @@ -42873,6 +42873,10 @@ exports['default'] = { return; } + if (input.value.slice(-4) !== '.zip') { + input.value += '.zip'; + } + var activeFile = _store2['default'].getState().get('activeFile'); this.props.dispatch((0, _actionsCompress.compress)(activeFile, input.value)); this.props.dispatch((0, _actionsDialog.hideAll)()); @@ -42998,13 +43002,13 @@ var entryMenu = { enabled: function enabled() { var active = _store2['default'].getState().get('activeFile'); - if (active) console.log(active[0].name); - return active && active[0].name.indexOf('.zip') > -1; + return active && active[0].name.slice(-4) === '.zip'; }, action: function action() { var active = _store2['default'].getState().get('activeFile'); _store2['default'].dispatch((0, _actionsCompress.decompress)(active)); + _store2['default'].dispatch((0, _actionsMenu.hideAll)()); } }, { name: 'Archive', @@ -43420,9 +43424,9 @@ exports['default'] = function (state, action) { var cwd = _store2['default'].getState().get('cwd'); var all = Promise.all(action.file.map(function addFile(file) { - console.log('addFile', file); var path = (0, _utils.normalize)((file.path || '') + file.name); var archivePath = path.slice(cwd.length); + console.log(archivePath); // directory if (!(file instanceof Blob)) { var folder = archive.folder(file.name); @@ -43430,19 +43434,12 @@ exports['default'] = function (state, action) { return (0, _apiFiles.children)(path).then(function (files) { return Promise.all(files.map(function (child) { return addFile(child); - - // return readFile(childPath).then(content => { - // let blob = new Blob([content]); - // folder.file(child.name, blob); - // }); })); }); } - console.log('readFile', path); return (0, _apiFiles.readFile)(path).then(function (content) { - console.log('readFile done', path); - archive.file(archivePath + '/' + file.name, content); + archive.file(archivePath, content); }); })); diff --git a/src/js/menus.js b/src/js/menus.js index bdd1749..1cb0e8f 100644 --- a/src/js/menus.js +++ b/src/js/menus.js @@ -71,13 +71,13 @@ const entryMenu = { enabled() { let active = store.getState().get('activeFile'); - if (active) console.log(active[0].name); - return active && active[0].name.indexOf('.zip') > -1; + return active && active[0].name.slice(-4) === '.zip'; }, action() { let active = store.getState().get('activeFile'); store.dispatch(decompress(active)); + store.dispatch(hideAll()); } }, { diff --git a/src/js/reducers/files.js b/src/js/reducers/files.js index ce9f601..4405a7b 100644 --- a/src/js/reducers/files.js +++ b/src/js/reducers/files.js @@ -88,9 +88,9 @@ export default function(state = [], action) { let cwd = store.getState().get('cwd'); let all = Promise.all(action.file.map(function addFile(file) { - console.log('addFile', file); let path = normalize((file.path || '') + file.name); let archivePath = path.slice(cwd.length); + console.log(archivePath); // directory if (!(file instanceof Blob)) { let folder = archive.folder(file.name); @@ -98,19 +98,12 @@ export default function(state = [], action) { return children(path).then(files => { return Promise.all(files.map(child => { return addFile(child); - - // return readFile(childPath).then(content => { - // let blob = new Blob([content]); - // folder.file(child.name, blob); - // }); })); - }) + }); } - console.log('readFile', path); return readFile(path).then(content => { - console.log('readFile done', path); - archive.file(archivePath + '/' + file.name, content); + archive.file(archivePath, content); }); }))