From 2ef1ac93842cec4382497c2e499225640b96218b Mon Sep 17 00:00:00 2001 From: emli Date: Mon, 19 Mar 2018 10:21:07 +0600 Subject: [PATCH] #298 Use storage path instead of tmp --- libgorjun/info_test.go | 12 ++++++------ template/template.go | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libgorjun/info_test.go b/libgorjun/info_test.go index c396488..118bd8b 100644 --- a/libgorjun/info_test.go +++ b/libgorjun/info_test.go @@ -331,12 +331,12 @@ func TestListPriority(t *testing.T) { g := NewGorjunServer() g.Register(g.Username) - //artifactType := "template" - //v.Upload("data/debian-stretch-subutai-template_0.2.3_amd64.tar.gz", "template", "false") - //err := g.Uploads(artifactType, "false") - //if err != nil { - // t.Errorf("Failed to uploads %s: %v", err, artifactType) - //} + artifactType := "template" + v.Upload("data/debian-stretch-subutai-template_0.2.3_amd64.tar.gz", "template", "false") + err := g.Uploads(artifactType, "false") + if err != nil { + t.Errorf("Failed to uploads %s: %v", err, artifactType) + } fmt.Println("Token for user " + g.Username + " = " + g.Token) fmt.Println("Token for user " + v.Username + " = " + v.Token) diff --git a/template/template.go b/template/template.go index b30ff8d..3f5911e 100644 --- a/template/template.go +++ b/template/template.go @@ -338,14 +338,14 @@ func ModifyConfig(w http.ResponseWriter, r *http.Request) { item := download.FormatItem(db.Info(k), "template", "") md5 := item.Hash.Md5 - configPath := "/tmp/foo/config" + configPath := config.Storage.Path + "/tmp/foo/config" - decompress(config.Storage.Path+md5, "/tmp/foo") + decompress(config.Storage.Path+md5, config.Storage.Path+"/tmp/foo") appendConfig(configPath, item) - compress("/tmp/foo", "/tmp/foo.tar.gz") + compress(config.Storage.Path+"/tmp/foo", config.Storage.Path+"/tmp/foo.tar.gz") updateMetaDB(item.ID, item.Owner[0], item.Hash.Md5, item.Filename, configPath) - os.RemoveAll("/tmp/foo") + os.RemoveAll(config.Storage.Path + "/tmp/foo") os.RemoveAll(config.Storage.Path + md5) } } @@ -364,8 +364,8 @@ func appendConfig(confPath string, item download.ListItem) { } func updateMetaDB(id, owner, hash, filename, configPath string) { - md5sum := upload.Hash("/tmp/foo.tar.gz") - sha256sum := upload.Hash("/tmp/foo.tar.gz", "sha256") + md5sum := upload.Hash(config.Storage.Path + "/tmp/foo.tar.gz") + sha256sum := upload.Hash(config.Storage.Path+"/tmp/foo.tar.gz", "sha256") if len(md5sum) == 0 || len(sha256sum) == 0 { log.Warn("Failed to calculate hash for " + hash) return @@ -391,7 +391,7 @@ func updateMetaDB(id, owner, hash, filename, configPath string) { "signature": t.Signature[owner], }) - err := os.Rename("/tmp/foo.tar.gz", config.Storage.Path+md5sum) + err := os.Rename(config.Storage.Path+"/tmp/foo.tar.gz", config.Storage.Path+md5sum) if err != nil { fmt.Println(err)