diff --git a/packages/app-desktop/gui/NoteEditor/utils/resourceHandling.ts b/packages/app-desktop/gui/NoteEditor/utils/resourceHandling.ts index 8bc1f040d..25067a838 100644 --- a/packages/app-desktop/gui/NoteEditor/utils/resourceHandling.ts +++ b/packages/app-desktop/gui/NoteEditor/utils/resourceHandling.ts @@ -5,7 +5,6 @@ import BaseModel from '@joplin/lib/BaseModel'; import Resource from '@joplin/lib/models/Resource'; const bridge = require('electron').remote.require('./bridge').default; import ResourceFetcher from '@joplin/lib/services/ResourceFetcher'; -import { reg } from '@joplin/lib/registry'; import htmlUtils from '@joplin/lib/htmlUtils'; import Logger from '@joplin/lib/Logger'; const joplinRendererUtils = require('@joplin/renderer').utils; @@ -14,6 +13,8 @@ const mimeUtils = require('@joplin/lib/mime-utils.js').mime; const md5 = require('md5'); const path = require('path'); +const logger = Logger.create('resourceHandling'); + export async function handleResourceDownloadMode(noteBody: string) { if (noteBody && Setting.value('sync.resourceDownloadMode') === 'auto') { const resourceIds = await Note.linkedResourceIds(noteBody); @@ -72,21 +73,21 @@ export async function commandAttachFileToBody(body: string, filePaths: string[] for (let i = 0; i < filePaths.length; i++) { const filePath = filePaths[i]; try { - reg.logger().info(`Attaching ${filePath}`); + logger.info(`Attaching ${filePath}`); const newBody = await shim.attachFileToNoteBody(body, filePath, options.position, { createFileURL: options.createFileURL, resizeLargeImages: 'ask', }); if (!newBody) { - reg.logger().info('File attachment was cancelled'); + logger.info('File attachment was cancelled'); return null; } body = newBody; - reg.logger().info('File was attached.'); + logger.info('File was attached.'); } catch (error) { - reg.logger().error(error); + logger.error(error); bridge().showErrorMessageBox(error.message); } } @@ -157,9 +158,8 @@ export async function processPastedHtml(html: string) { await shim.fsDriver().remove(filePath); mappedResources[imageSrc] = `file://${Resource.fullPath(createdResource)}`; } - } catch (err) { - const logger = Logger.create('resourceHandling'); - logger.warn(`Error creating a resource for ${imageSrc}.`, err); + } catch (error) { + logger.warn(`Error creating a resource for ${imageSrc}.`, error); mappedResources[imageSrc] = imageSrc; } }