diff options
author | Ollie Phillips <oliver@eantics.co.uk> | 2019-03-26 09:28:27 +0000 |
---|---|---|
committer | Ollie Phillips <oliver@eantics.co.uk> | 2019-03-26 09:28:27 +0000 |
commit | 9348a3e6cd0a1e2b0cd6611b1f7acb04307544e7 (patch) | |
tree | 9310d687111aba8fa9bff2816313a1773a640b50 /system | |
parent | ec7b5b2bab2cad13db317a017fb8ee5d32a8f68c (diff) |
use filepath.Join for best OS compatiblity
Diffstat (limited to 'system')
-rw-r--r-- | system/admin/filesystem.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/system/admin/filesystem.go b/system/admin/filesystem.go index 21e9740..e556ec8 100644 --- a/system/admin/filesystem.go +++ b/system/admin/filesystem.go @@ -4,6 +4,7 @@ import ( "encoding/json" "net/http" "os" + "path/filepath" "strings" "github.com/ponzu-cms/ponzu/system/db" @@ -23,9 +24,11 @@ func deleteUploadFromDisk(target string) error { return err } + // split and rebuild path in OS friendly way // use path to delete the physical file from disk - delPath := strings.Replace(upload.Path, "/api/", "./", 1) - err = os.Remove(delPath) + pathSplit := strings.Split(upload.Path, "/") + pathJoin := filepath.Join(pathSplit[2:]...) + err = os.Remove(pathJoin) if err != nil { return err } |