From b4aaba79ce3947a9c62a22f46bdd8c836a56fd90 Mon Sep 17 00:00:00 2001 From: trivernis Date: Fri, 24 Jan 2020 15:03:35 +0100 Subject: [PATCH] Hotfix crash when starting due to cleanup --- src/lib/dataAccess.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib/dataAccess.ts b/src/lib/dataAccess.ts index 668c8b1..399a366 100644 --- a/src/lib/dataAccess.ts +++ b/src/lib/dataAccess.ts @@ -79,12 +79,17 @@ namespace dataaccess { * - deletes all media entries without associations */ async function databaseCleanup() { - const allMedia = await models.Media - .findAll({include: [models.Post, models.User, models.Group]}) as models.Media[]; - for (const media of allMedia) { - if (!media.user && !media.post && !media.group) { - await media.destroy(); + try { + const allMedia = await models.Media + .findAll({include: [models.Post, models.User, models.Group]}) as models.Media[]; + for (const media of allMedia) { + if (!media.user && !media.post && !media.group) { + await media.destroy(); + } } + } catch (err) { + globals.logger.error(err.message); + globals.logger.debug(err.stack); } }