1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-02 22:49:09 +02:00

All: Improved file and memory drivers to make it easier to use same sync method for all the drivers

This commit is contained in:
Laurent Cozic
2017-12-18 21:47:25 +01:00
parent 2959fa1080
commit 26bf7c4d46
2 changed files with 36 additions and 12 deletions

View File

@@ -151,12 +151,6 @@ class FileApiDriverLocal {
} else {
output = await fs.readFile(path, options.encoding);
}
// if (options.encoding == 'binary') {
// output = await fs.readFile(path);
// } else {
// output = await fs.readFile(path, options.encoding);
// }
} catch (error) {
if (error.code == 'ENOENT') return null;
throw this.fsErrorToJsError_(error);
@@ -184,7 +178,11 @@ class FileApiDriverLocal {
});
}
put(path, content) {
async put(path, content, options = null) {
if (!options) options = {};
if (options.source === 'file') content = await fs.readFile(options.path);
return new Promise((resolve, reject) => {
fs.writeFile(path, content, function(error) {
if (error) {