From 9421fa34a85ead8229f0a10919788473c2cabf68 Mon Sep 17 00:00:00 2001 From: Sotirios Pupakis Date: Mon, 8 Sep 2025 03:52:22 +0200 Subject: [PATCH] delete old version files --- controllers/indexerController.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/controllers/indexerController.go b/controllers/indexerController.go index 1adc480..323e48c 100644 --- a/controllers/indexerController.go +++ b/controllers/indexerController.go @@ -83,6 +83,13 @@ func SaveIndexingResult(c *gin.Context) { return } + // get all files for this addon and delete them - old version + ret = initializers.DB.Where("addon_id = ?", addon.ID).Delete(&models.AddonFile{}) + if ret.Error != nil { + c.JSON(500, gin.H{"error": ret.Error.Error()}) + return + } + ret = initializers.DB.CreateInBatches(&result.Files, 100) if ret.Error != nil { c.JSON(500, gin.H{"error": ret.Error.Error()})