fix(archive): fix all files being put into folders while archiving

This commit is contained in:
Mahdi Dibaiee 2015-10-26 15:44:54 +03:30
parent 4253732492
commit bec675e7ee
3 changed files with 13 additions and 23 deletions

View File

@ -42873,6 +42873,10 @@ exports['default'] = {
return; return;
} }
if (input.value.slice(-4) !== '.zip') {
input.value += '.zip';
}
var activeFile = _store2['default'].getState().get('activeFile'); var activeFile = _store2['default'].getState().get('activeFile');
this.props.dispatch((0, _actionsCompress.compress)(activeFile, input.value)); this.props.dispatch((0, _actionsCompress.compress)(activeFile, input.value));
this.props.dispatch((0, _actionsDialog.hideAll)()); this.props.dispatch((0, _actionsDialog.hideAll)());
@ -42998,13 +43002,13 @@ var entryMenu = {
enabled: function enabled() { enabled: function enabled() {
var active = _store2['default'].getState().get('activeFile'); var active = _store2['default'].getState().get('activeFile');
if (active) console.log(active[0].name); return active && active[0].name.slice(-4) === '.zip';
return active && active[0].name.indexOf('.zip') > -1;
}, },
action: function action() { action: function action() {
var active = _store2['default'].getState().get('activeFile'); var active = _store2['default'].getState().get('activeFile');
_store2['default'].dispatch((0, _actionsCompress.decompress)(active)); _store2['default'].dispatch((0, _actionsCompress.decompress)(active));
_store2['default'].dispatch((0, _actionsMenu.hideAll)());
} }
}, { }, {
name: 'Archive', name: 'Archive',
@ -43420,9 +43424,9 @@ exports['default'] = function (state, action) {
var cwd = _store2['default'].getState().get('cwd'); var cwd = _store2['default'].getState().get('cwd');
var all = Promise.all(action.file.map(function addFile(file) { var all = Promise.all(action.file.map(function addFile(file) {
console.log('addFile', file);
var path = (0, _utils.normalize)((file.path || '') + file.name); var path = (0, _utils.normalize)((file.path || '') + file.name);
var archivePath = path.slice(cwd.length); var archivePath = path.slice(cwd.length);
console.log(archivePath);
// directory // directory
if (!(file instanceof Blob)) { if (!(file instanceof Blob)) {
var folder = archive.folder(file.name); var folder = archive.folder(file.name);
@ -43430,19 +43434,12 @@ exports['default'] = function (state, action) {
return (0, _apiFiles.children)(path).then(function (files) { return (0, _apiFiles.children)(path).then(function (files) {
return Promise.all(files.map(function (child) { return Promise.all(files.map(function (child) {
return addFile(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) { return (0, _apiFiles.readFile)(path).then(function (content) {
console.log('readFile done', path); archive.file(archivePath, content);
archive.file(archivePath + '/' + file.name, content);
}); });
})); }));

View File

@ -71,13 +71,13 @@ const entryMenu = {
enabled() { enabled() {
let active = store.getState().get('activeFile'); let active = store.getState().get('activeFile');
if (active) console.log(active[0].name); return active && active[0].name.slice(-4) === '.zip';
return active && active[0].name.indexOf('.zip') > -1;
}, },
action() { action() {
let active = store.getState().get('activeFile'); let active = store.getState().get('activeFile');
store.dispatch(decompress(active)); store.dispatch(decompress(active));
store.dispatch(hideAll());
} }
}, },
{ {

View File

@ -88,9 +88,9 @@ export default function(state = [], action) {
let cwd = store.getState().get('cwd'); let cwd = store.getState().get('cwd');
let all = Promise.all(action.file.map(function addFile(file) { let all = Promise.all(action.file.map(function addFile(file) {
console.log('addFile', file);
let path = normalize((file.path || '') + file.name); let path = normalize((file.path || '') + file.name);
let archivePath = path.slice(cwd.length); let archivePath = path.slice(cwd.length);
console.log(archivePath);
// directory // directory
if (!(file instanceof Blob)) { if (!(file instanceof Blob)) {
let folder = archive.folder(file.name); let folder = archive.folder(file.name);
@ -98,19 +98,12 @@ export default function(state = [], action) {
return children(path).then(files => { return children(path).then(files => {
return Promise.all(files.map(child => { return Promise.all(files.map(child => {
return addFile(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 => { return readFile(path).then(content => {
console.log('readFile done', path); archive.file(archivePath, content);
archive.file(archivePath + '/' + file.name, content);
}); });
})) }))