diff --git a/ReactNativeClient/lib/import-enex.js b/ReactNativeClient/lib/import-enex.js index d1cf16c5a..f5b0aa5af 100644 --- a/ReactNativeClient/lib/import-enex.js +++ b/ReactNativeClient/lib/import-enex.js @@ -150,17 +150,10 @@ async function processNoteResource(resource) { return resource; } -async function saveNoteResources(note, importOptions) { +async function saveNoteResources(note) { let resourcesCreated = 0; for (let i = 0; i < note.resources.length; i++) { - let resource = note.resources[i]; - - try { - resource = await processNoteResource(resource); - } catch (error) { - importOptions.onError(error); - continue; - } + const resource = note.resources[i]; const toSave = Object.assign({}, resource); delete toSave.dataFilePath; @@ -298,6 +291,20 @@ function importEnex(parentFolderId, filePath, importOptions = null) { while (notes.length) { const note = notes.shift(); + + for (let i = 0; i < note.resources.length; i++) { + let resource = note.resources[i]; + + try { + resource = await processNoteResource(resource); + } catch (error) { + importOptions.onError(error); + continue; + } + + note.resources[i] = resource; + } + const body = importOptions.outputFormat === 'html' ? await enexXmlToHtml(note.bodyXml, note.resources) : await enexXmlToMd(note.bodyXml, note.resources);