Hotfix crash when starting due to cleanup

pull/5/head
trivernis 5 years ago
parent ee60508953
commit b4aaba79ce

@ -79,12 +79,17 @@ namespace dataaccess {
* - deletes all media entries without associations * - deletes all media entries without associations
*/ */
async function databaseCleanup() { async function databaseCleanup() {
const allMedia = await models.Media try {
.findAll({include: [models.Post, models.User, models.Group]}) as models.Media[]; const allMedia = await models.Media
for (const media of allMedia) { .findAll({include: [models.Post, models.User, models.Group]}) as models.Media[];
if (!media.user && !media.post && !media.group) { for (const media of allMedia) {
await media.destroy(); if (!media.user && !media.post && !media.group) {
await media.destroy();
}
} }
} catch (err) {
globals.logger.error(err.message);
globals.logger.debug(err.stack);
} }
} }

Loading…
Cancel
Save