mirror of
https://github.com/zadam/trilium.git
synced 2025-11-18 03:00:41 +01:00
improved ZIP import validation and error handling
This commit is contained in:
@@ -231,6 +231,13 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
|
||||
absUrl += `${absUrl.length > 0 ? '/' : ''}${url}`;
|
||||
|
||||
const {noteMeta} = getMeta(absUrl);
|
||||
|
||||
if (!noteMeta) {
|
||||
log.info(`Could not find note meta for URL '${absUrl}'.`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const targetNoteId = getNoteId(noteMeta, absUrl);
|
||||
return targetNoteId;
|
||||
}
|
||||
@@ -312,6 +319,10 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
|
||||
|
||||
const targetNoteId = getNoteIdFromRelativeUrl(url, filePath);
|
||||
|
||||
if (!targetNoteId) {
|
||||
return match;
|
||||
}
|
||||
|
||||
return `src="api/images/${targetNoteId}/${path.basename(url)}"`;
|
||||
});
|
||||
|
||||
@@ -329,6 +340,10 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
|
||||
|
||||
const targetNoteId = getNoteIdFromRelativeUrl(url, filePath);
|
||||
|
||||
if (!targetNoteId) {
|
||||
return match;
|
||||
}
|
||||
|
||||
return `href="#root/${targetNoteId}"`;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user