filtre folder media

This commit is contained in:
cangui 2025-06-21 17:54:44 +02:00
parent 44cf222bf5
commit 3fc81e5c80

View File

@ -82,10 +82,15 @@ func Login(w http.ResponseWriter, r *http.Request){
func Dashboard(db *gorm.DB)http.HandlerFunc { func Dashboard(db *gorm.DB)http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
var paths []models.PathDownload var paths []models.PathDownload
if err := db.Find(&paths).Error; err != nil { root := "/app/upload"
http.Error(w, `{"error": "Failed to retrieve paths"}`, http.StatusInternalServerError)
return // on sélectionne tout ce qui est sous /app/upload/, mais pas plus loin quun 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{}{ data := map[string]interface{}{
"paths": paths, "paths": paths,
} }