1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Fixes #1854: Prevent external editor from clearing the note in some hard to replicate cases

This commit is contained in:
Laurent Cozic 2019-10-12 21:30:38 +02:00
parent ec67bc7f1a
commit 6dec711a0a

View File

@ -77,6 +77,17 @@ class ExternalEditWatcher {
}
const noteContent = await shim.fsDriver().readFile(path, 'utf-8');
// Hack to prevent very hard to replicate bug:
// https://github.com/laurent22/joplin/issues/1854
// It means that if user wants to clear the note (including title) from external editor
// it won't work. But it's a more acceptable bug than clearing the note when not asking
// for it.
if (!noteContent) {
this.logger().warn(`Watched note is empty - this is likely to be a bug so won't save: ${id}`);
return;
}
const updatedNote = await Note.unserializeForEdit(noteContent);
updatedNote.id = id;
updatedNote.parent_id = note.parent_id;