From 5b08d6f7767380fb895ee2c269868ed2b3123b7c Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Tue, 15 Jul 2025 09:59:50 -0500 Subject: [PATCH] Sentry fix: Quickpreview inside app.asar bundle on snap --- app/build/tasks/package-task.js | 1 + app/src/quickpreview/index.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/build/tasks/package-task.js b/app/build/tasks/package-task.js index 26e511a16..0f3cca040 100644 --- a/app/build/tasks/package-task.js +++ b/app/build/tasks/package-task.js @@ -167,6 +167,7 @@ module.exports = grunt => { '**/vendor/**', 'examples/**', '**/src/tasks/**', + '**/src/quickpreview/**', '**/static/all_licenses.html', '**/static/extensions/**', '**/node_modules/spellchecker/**', diff --git a/app/src/quickpreview/index.ts b/app/src/quickpreview/index.ts index 3bd9561d5..f606aa304 100644 --- a/app/src/quickpreview/index.ts +++ b/app/src/quickpreview/index.ts @@ -6,10 +6,12 @@ let quickPreviewWindow = null; let captureWindow = null; const captureQueue = []; +const filesRoot = __dirname.replace('app.asar', 'app.asar.unpacked'); + const FileSizeLimit = 5 * 1024 * 1024; const ThumbnailWidth = 320 * (11 / 8.5); const QuicklookIsAvailable = process.platform === 'darwin'; -const PDFJSRoot = path.join(__dirname, 'pdfjs-4.3.136'); +const PDFJSRoot = path.join(filesRoot, 'pdfjs-4.3.136'); const QuicklookBlacklist = [ 'jpg', @@ -198,7 +200,7 @@ export function displayQuickPreviewWindow(filePath) { skipTaskbar: true, backgroundColor: isPDF ? '#404040' : '#FFF', webPreferences: { - preload: path.join(__dirname, 'preload.js'), + preload: path.join(filesRoot, 'preload.js'), nodeIntegration: false, contextIsolation: true, }, @@ -219,7 +221,7 @@ export function displayQuickPreviewWindow(filePath) { search: `file=${encodeURIComponent(`file://${filePath}`)}`, }); } else { - quickPreviewWindow.loadFile(path.join(__dirname, 'renderer.html'), { + quickPreviewWindow.loadFile(path.join(filesRoot, 'renderer.html'), { search: JSON.stringify({ mode: 'display', filePath, strategy }), }); } @@ -265,7 +267,7 @@ function _createCaptureWindow() { height: ThumbnailWidth, show: false, webPreferences: { - preload: path.join(__dirname, 'preload.js'), + preload: path.join(filesRoot, 'preload.js'), nodeIntegration: false, contextIsolation: true, }, @@ -295,7 +297,7 @@ function _generateNextCrossplatformPreview() { const { strategy, filePath, previewPath, resolve } = captureQueue.pop(); // Start the thumbnail generation - captureWindow.loadFile(path.join(__dirname, 'renderer.html'), { + captureWindow.loadFile(path.join(filesRoot, 'renderer.html'), { search: JSON.stringify({ strategy, mode: 'capture', filePath, previewPath }), });