From 3fc81e5c80978f73fd851911344362b8239dd6f2 Mon Sep 17 00:00:00 2001 From: cangui Date: Sat, 21 Jun 2025 17:54:44 +0200 Subject: [PATCH] filtre folder media --- renders/renders.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/renders/renders.go b/renders/renders.go index 0180f49..cf2b83d 100644 --- a/renders/renders.go +++ b/renders/renders.go @@ -82,10 +82,15 @@ func Login(w http.ResponseWriter, r *http.Request){ func Dashboard(db *gorm.DB)http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var paths []models.PathDownload - if err := db.Find(&paths).Error; err != nil { - http.Error(w, `{"error": "Failed to retrieve paths"}`, http.StatusInternalServerError) - return - } + root := "/app/upload" + + // on sélectionne tout ce qui est sous /app/upload/, mais pas plus loin qu’un seul slash en plus + if err := db. + Where("path LIKE ? AND path NOT LIKE ?", root+"/%", root+"/%/%"). + Find(&paths).Error; err != nil { + http.Error(w, `{"error": "Failed to retrieve paths"}`, http.StatusInternalServerError) + return + } data := map[string]interface{}{ "paths": paths, }