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;
}
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);
});
}));

View File

@ -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());
}
},
{

View File

@ -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);
});
}))