From 9348a3e6cd0a1e2b0cd6611b1f7acb04307544e7 Mon Sep 17 00:00:00 2001 From: Ollie Phillips Date: Tue, 26 Mar 2019 09:28:27 +0000 Subject: use filepath.Join for best OS compatiblity --- system/admin/filesystem.go | 7 +++++-- 1 file 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 } -- cgit v1.2.3