From c52832795f36beb302866059c19cb2befc4dc1bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Am=C3=A9lie=20Loulergue?= Date: Sun, 1 Dec 2024 06:41:22 +0100 Subject: [PATCH] add clean catalog on server.ts --- src/api/server.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/api/server.ts b/src/api/server.ts index 5179d69..a6c4835 100644 --- a/src/api/server.ts +++ b/src/api/server.ts @@ -5,6 +5,7 @@ import { redisHandler } from './catalog/redis/connection'; import { getLastDump } from './delegated-storage/index'; import { minioClient } from './delegated-storage/s3/connection'; import fetch from 'node-fetch'; +import { deleteCatalogItem, getCatalog } from './catalog'; const port = parseInt(process.env.PORT, 10) || 3001; const standalone = process.env.DELEGATED_STORAGE_METHOD === 'STANDALONE'; @@ -34,6 +35,14 @@ const connectToRedisWithRetry = async (maxRetries, delay) => { while (attempts < maxRetries) { try { await redisHandler.connectClient(); + const {data:catalog} = await getCatalog() + if(catalog.length){ + for (const item of catalog){ + if(item.unique_name.includes('/tests/')){ + await deleteCatalogItem(item.unique_name) + } + } + } return; } catch (err) { attempts++;