filtre folder media

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

View File

@ -82,7 +82,12 @@ 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 {
root := "/app/upload"
// 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
}