From 9b79aab4d5b8604f8535d32340b965d65f665818 Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Mon, 17 Mar 2025 19:58:55 +0100 Subject: [PATCH] logging --- server/controllers/LibraryController.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/server/controllers/LibraryController.js b/server/controllers/LibraryController.js index f51b4974..5ca80115 100644 --- a/server/controllers/LibraryController.js +++ b/server/controllers/LibraryController.js @@ -1452,15 +1452,24 @@ class LibraryController { const filename = `LibraryItems-${Date.now()}.zip` const libraryItemPaths = libraryItems.map((li) => li.path) - - console.log(libraryItemPaths) + try { await zipHelpers.zipDirectoriesPipe(libraryItemPaths, filename, res) Logger.info(`[LibraryItemController] Downloaded item "${filename}" at "${libraryItemPaths}"`) } catch (error) { Logger.error(`[LibraryItemController] Download failed for item "${filename}" at "${libraryItemPaths}"`, error) - //LibraryItemController.handleDownloadError(error, res) + LibraryController.handleDownloadError(error, res) + } + } + + static handleDownloadError(error, res) { + if (!res.headersSent) { + if (error.code === 'ENOENT') { + return res.status(404).send('File not found') + } else { + return res.status(500).send('Download failed') + } } }