로그파일 전송 오류 수정
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
@ -128,8 +129,7 @@ func (h *houstonHandler) RegisterHandlers(serveMux gocommon.ServerMuxInterface,
|
||||
defer func() {
|
||||
s := recover()
|
||||
if s != nil {
|
||||
logger.Println(s)
|
||||
debug.PrintStack()
|
||||
logger.Error(s)
|
||||
}
|
||||
io.Copy(io.Discard, r.Body)
|
||||
r.Body.Close()
|
||||
@ -140,12 +140,25 @@ func (h *houstonHandler) RegisterHandlers(serveMux gocommon.ServerMuxInterface,
|
||||
filename := r.Header.Get("Houston-Service-Filename")
|
||||
dir := path.Join(h.downloadPath, name, version)
|
||||
if err := os.MkdirAll(dir, 0775); err == nil {
|
||||
file, _ := os.Create(path.Join(dir, filename))
|
||||
if file != nil {
|
||||
defer file.Close()
|
||||
if _, err = io.Copy(file, r.Body); err != nil {
|
||||
zipfile, _ := os.Create(path.Join(dir, filename))
|
||||
logger.Println("file uploaded :", zipfile)
|
||||
if zipfile != nil {
|
||||
if _, err = io.Copy(zipfile, r.Body); err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
} else {
|
||||
if strings.HasSuffix(filename, ".zip") {
|
||||
stat, _ := zipfile.Stat()
|
||||
zipreader, _ := zip.NewReader(zipfile, stat.Size())
|
||||
for _, f := range zipreader.File {
|
||||
file, _ := os.Create(path.Join(dir, f.Name))
|
||||
comp, _ := f.Open()
|
||||
io.Copy(file, comp)
|
||||
file.Close()
|
||||
}
|
||||
defer os.Remove(path.Join(dir, filename))
|
||||
}
|
||||
}
|
||||
zipfile.Close()
|
||||
} else {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user