Skip to content

Build your personal knowledge base with Trilium Notes

fix exporting root note, closes #1024

zadamfa5d982a553e
diff --git a/src/public/app/services/tree.js b/src/public/app/services/tree.js
index 4910f4c366..40254a890c 100644
--- a/src/public/app/services/tree.js
+++ b/src/public/app/services/tree.js
@@ -162,6 +162,13 @@ function getNoteIdFromNotePath(notePath) {
}
function getNoteIdAndParentIdFromNotePath(notePath) {
+ if (notePath === 'root') {
+ return {
+ noteId: 'root',
+ parentNoteId: 'none'
+ };
+ }
+
let parentNoteId = 'root';
let noteId = '';
@@ -286,4 +293,4 @@ export default {
getNotePathTitle,
getHashValueFromAddress,
parseNotePath
-};
\ No newline at end of file
+};
diff --git a/src/routes/api/export.js b/src/routes/api/export.js
index 7464c793a0..109b9bb7bd 100644
--- a/src/routes/api/export.js
+++ b/src/routes/api/export.js
@@ -11,6 +11,14 @@ async function exportBranch(req, res) {
const {branchId, type, format, version, taskId} = req.params;
const branch = await repository.getBranch(branchId);
+ if (!branch) {
+ const message = `Cannot export branch ${branchId} since it does not exist.`;
+ log.error(message);
+
+ res.status(500).send(message);
+ return;
+ }
+
const taskContext = new TaskContext(taskId, 'export');
try {
@@ -39,4 +47,4 @@ async function exportBranch(req, res) {
module.exports = {
exportBranch
-};
\ No newline at end of file
+};