From 3e99587988895396e769301cae6c6ecd86984037 Mon Sep 17 00:00:00 2001 From: snt Date: Tue, 24 Jun 2025 11:04:56 +0000 Subject: [PATCH] check no childs less verbose output --- index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index dc1030d..87672b2 100644 --- a/index.js +++ b/index.js @@ -96,7 +96,6 @@ const plugin = { const now = Math.floor(Date.now()) const cut_datetime = now - plugin.settings?.deadline_time*60*60*1000 const date_obj = new Date(cut_datetime) - plugin.log.debug("now %s -- deadline %s", now, cut_datetime) plugin.log.info("[Cleaner Plugin] Removing old events before " + date_obj) events = await plugin.db.models.event.findAll({ where: { @@ -109,16 +108,16 @@ const plugin = { limit: plugin.settings.events_number, }) - plugin.log.warn("[Cleaner Plugin] Found %s past events and related resources.", events.length) - if (!events.length) { return } + plugin.log.info("[Cleaner Plugin] Found %s past events and related resources.", events.length) + for (e of events) { end_date = new Date(e.end_datetime * 1000) start_date = new Date(e.start_datetime * 1000) - plugin.log.info("[Cleaner Plugin] Cleaning: " + e.title + " - Rec: " + e.recurrent + " - From: " + start_date + " - To: " + end_date + " - place: " + e.placeId) + plugin.log.info("[Cleaner Plugin] Cleaning: " + e.title + " - From: " + start_date + " - To: " + end_date) plugin.log.debug("[Cleaner Plugin] %s", JSON.stringify(e, null, "\t")) - if (e.media && e.media.length && !e.recurrent && !e.parentId) { + if (e.media && e.media.length && !e.recurrent && !e.parentId && !e.child.length) { try { const old_path = path.join(config.upload_path, e.media[0].url) const old_thumb_path = path.join(config.upload_path, 'thumb', e.media[0].url) @@ -128,6 +127,8 @@ const plugin = { } catch (excep) { plugin.log.error("[Cleaner Plugin] error removing file %s", excep.toString()) } + } else { + plugin.log.debug("[Cleaner Plugin] skip cleaning media file") } try { // notify local events before destroying notifications