Fix purging default file from HTTP cache
This commit is contained in:
parent
52df872198
commit
48678fb4c6
2 changed files with 13 additions and 4 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
- Fix better naming for storage endpoint documentation
|
- Fix better naming for storage endpoint documentation
|
||||||
- Fix freeing up S3 mounts
|
- Fix freeing up S3 mounts
|
||||||
- Fix URL validation if the path contains FFmpeg specific placeholders
|
- Fix URL validation if the path contains FFmpeg specific placeholders
|
||||||
|
- Fix purging default file from HTTP cache
|
||||||
|
|
||||||
### Core v16.11.0 > v16.12.0
|
### Core v16.11.0 > v16.12.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/datarhei/core/v16/http/api"
|
"github.com/datarhei/core/v16/http/api"
|
||||||
"github.com/datarhei/core/v16/http/fs"
|
"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)
|
size := h.fs.Filesystem.Remove(path)
|
||||||
|
|
||||||
if size < 0 {
|
|
||||||
return api.Err(http.StatusNotFound, "File not found", path)
|
|
||||||
}
|
|
||||||
|
|
||||||
if h.fs.Cache != nil {
|
if h.fs.Cache != nil {
|
||||||
h.fs.Cache.Delete(path)
|
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)
|
return c.String(http.StatusOK, "Deleted: "+path)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue