@ -92,6 +92,15 @@ export async function readFile(path) {
|
||||
}
|
||||
|
||||
export async function writeFile(path, content) {
|
||||
try {
|
||||
let file = await getFile(path);
|
||||
|
||||
return Promise.reject(new Error('File already exists: ' + path));
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
let request = sdcard().addNamed(content, path);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -9,7 +9,6 @@ export default class Breadcrumb extends Component {
|
||||
let els = [];
|
||||
|
||||
if (this.props.search) {
|
||||
console.log('search');
|
||||
els = [
|
||||
<span key='000'>Search: {this.props.search}</span>
|
||||
]
|
||||
|
@ -107,18 +107,20 @@ export default function(state = [], action) {
|
||||
})
|
||||
}
|
||||
|
||||
console.log('readFile', path);
|
||||
return readFile(path).then(content => {
|
||||
console.log('readFile done', path);
|
||||
archive.file(archivePath + '/' + file.name, content);
|
||||
});
|
||||
}))
|
||||
|
||||
all.then(() => {
|
||||
let buffer = archive.generate({ type: 'nodebuffer' });
|
||||
console.log(buffer);
|
||||
let blob = new Blob([buffer], { type: 'application/zip' });
|
||||
|
||||
let cwd = store.getState().get('cwd');
|
||||
let path = normalize(cwd + '/' + action.name);
|
||||
console.log(path);
|
||||
return writeFile(path, blob);
|
||||
}).then(boundRefresh).catch(reportError);
|
||||
|
||||
|
@ -27,7 +27,8 @@ export function getKey(object = store.getState().toJS(), key) {
|
||||
|
||||
export function reportError(err) {
|
||||
console.error(err);
|
||||
let action = show('errorDialog', {description: err.message});
|
||||
let msg = err.message || err.target.error.message;
|
||||
let action = show('errorDialog', {description: msg});
|
||||
store.dispatch(action);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user