From 7d59377309395bb779bc79d54485133097b2a73e Mon Sep 17 00:00:00 2001 From: Tyler Date: Thu, 14 Sep 2017 00:11:44 -0400 Subject: [PATCH] Don't prepend temp, use subdir --- src/meow.tf/deb-simple/http.go | 13 ++++++++++++- src/meow.tf/deb-simple/server.go | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/meow.tf/deb-simple/http.go b/src/meow.tf/deb-simple/http.go index c964e60..cdd26ae 100644 --- a/src/meow.tf/deb-simple/http.go +++ b/src/meow.tf/deb-simple/http.go @@ -97,6 +97,17 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { modifiedArches := make(map[string]bool) + baseDir := path.Join(os.TempDir(), "deb-simple") + + if _, err := os.Stat(baseDir); err != nil { + if os.IsNotExist(err) { + if err := os.MkdirAll(baseDir, 0755); err != nil { + httpErrorf(w, "error creating path: %s", err) + return + } + } + } + for { part, err := reader.NextPart() @@ -108,7 +119,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { continue } - tempFile := path.Join(os.TempDir(), "temp_" + part.FileName()) + tempFile := path.Join(baseDir, part.FileName()) dst, err := os.Create(tempFile) diff --git a/src/meow.tf/deb-simple/server.go b/src/meow.tf/deb-simple/server.go index fd5c8c9..d067b05 100644 --- a/src/meow.tf/deb-simple/server.go +++ b/src/meow.tf/deb-simple/server.go @@ -15,7 +15,7 @@ import ( "github.com/go-ini/ini" ) -var VERSION string = "1.3.2" +var VERSION string = "1.3.3" func packageName(name string) string { if index := strings.Index(name, "_"); index != -1 {