mirror of
https://github.com/datarhei/core.git
synced 2025-09-26 20:11:29 +08:00
Fix purging default file from HTTP cache
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
- Fix better naming for storage endpoint documentation
|
||||
- Fix freeing up S3 mounts
|
||||
- Fix URL validation if the path contains FFmpeg specific placeholders
|
||||
- Fix purging default file from HTTP cache
|
||||
|
||||
### Core v16.11.0 > v16.12.0
|
||||
|
||||
|
@@ -4,6 +4,7 @@ import (
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/datarhei/core/v16/http/api"
|
||||
"github.com/datarhei/core/v16/http/fs"
|
||||
@@ -107,12 +108,19 @@ func (h *FSHandler) DeleteFile(c echo.Context) error {
|
||||
|
||||
size := h.fs.Filesystem.Remove(path)
|
||||
|
||||
if size < 0 {
|
||||
return api.Err(http.StatusNotFound, "File not found", path)
|
||||
}
|
||||
|
||||
if h.fs.Cache != nil {
|
||||
h.fs.Cache.Delete(path)
|
||||
|
||||
if len(h.fs.DefaultFile) != 0 {
|
||||
if strings.HasSuffix(path, "/"+h.fs.DefaultFile) {
|
||||
path := strings.TrimSuffix(path, h.fs.DefaultFile)
|
||||
h.fs.Cache.Delete(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if size < 0 {
|
||||
return api.Err(http.StatusNotFound, "File not found", path)
|
||||
}
|
||||
|
||||
return c.String(http.StatusOK, "Deleted: "+path)
|
||||
|
Reference in New Issue
Block a user