admin: Implement button to delete the entire FILES dir
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
68dad00930
commit
a14c151b04
3 changed files with 34 additions and 1 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
|
@ -143,12 +144,27 @@ func listFiles(c *gin.Context) {
|
|||
}
|
||||
|
||||
func clearFiles(c *gin.Context) {
|
||||
_, err := fic.ClearFiles()
|
||||
err := os.RemoveAll(fic.FilesDir)
|
||||
if err != nil {
|
||||
log.Println("Unable to remove files:", err.Error())
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
err = os.MkdirAll(fic.FilesDir, 0751)
|
||||
if err != nil {
|
||||
log.Println("Unable to create FILES:", err.Error())
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
_, err = fic.ClearFiles()
|
||||
if err != nil {
|
||||
log.Println("Unable to clean DB files:", err.Error())
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Les fichiers ont bien été effacés. Mais il n'a pas été possible d'effacer la base de données. Refaites une synchronisation maintenant. " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue