1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-21 23:17:42 +02:00

Refactored Interop service to make export/import code more modular

This commit is contained in:
Laurent Cozic
2018-02-26 19:25:54 +00:00
parent d7fd8944f7
commit 45845f645d
13 changed files with 490 additions and 326 deletions

View File

@ -140,14 +140,22 @@ class FsDriverNode extends FsDriverBase {
}
}
readFile(path, encoding = 'utf8') {
if (encoding === 'Buffer') return fs.readFile(path); // Returns the raw buffer
return fs.readFile(path, encoding);
async readFile(path, encoding = 'utf8') {
try {
if (encoding === 'Buffer') return await fs.readFile(path); // Returns the raw buffer
return await fs.readFile(path, encoding);
} catch (error) {
throw this.fsErrorToJsError_(error, path);
}
}
// Always overwrite destination
async copy(source, dest) {
return fs.copy(source, dest, { overwrite: true });
try {
return await fs.copy(source, dest, { overwrite: true });
} catch (error) {
throw this.fsErrorToJsError_(error, source);
}
}
async unlink(path) {