提交 65bb9ba7 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

remove special char in download url

上级 5a22c712
......@@ -59,15 +59,15 @@ func (s *CronService) heartBeat() {
}
// has task to run,register busy, then run
//build := s.taskService.Peek()
build := s.taskService.Peek()
s.heartBeatService.HeartBeat(true)
// run
//s.taskService.Start()
//
//s.execService.Exec(build)
//
//s.taskService.Remove()
//s.taskService.End()
s.taskService.Start()
s.execService.Exec(build)
s.taskService.Remove()
s.taskService.End()
}
}
......@@ -16,6 +16,7 @@ import (
"net/http"
"os"
"strconv"
"strings"
)
type Server struct {
......@@ -162,7 +163,7 @@ func (s *Server) post(req *http.Request) (resp domain.RespData, err error) {
func Download(w http.ResponseWriter, fi string) {
logDir := vari.ZTFDir + "log-agent" + constant.PthSep
file, _ := os.Open(logDir + fi)
file, _ := os.Open(logDir + strings.Replace(fi, "-", "/", 1))
defer file.Close()
fileHeader := make([]byte, 512)
......
......@@ -71,7 +71,7 @@ func (s *TaskService) ListHistory() (data []map[string]string) {
data = serverUtils.ListHistoryLog()
for key, item := range data {
data[key]["url"] = fmt.Sprintf("http://%s:%s/down?f=%s", vari.IP, strconv.Itoa(vari.Port), item["name"])
data[key]["url"] = fmt.Sprintf("http://%s:%s/download?f=%s", vari.IP, strconv.Itoa(vari.Port), item["name"])
}
return
......
......@@ -15,8 +15,8 @@ import (
func BakLog(src string) {
now := time.Now()
dateStr := dateUtils.DateStr(now)
timeStr := dateUtils.TimeStr(now)
dateStr := dateUtils.DateStrNoSep(now)
timeStr := dateUtils.TimeStrNoSep(now)
dateDir := vari.AgentLogDir + dateStr + constant.PthSep
dist := dateDir + timeStr + ".zip"
......@@ -34,12 +34,12 @@ func removeHistoryLog(root string) {
for _, dir := range dirs {
name := dir.Name()
pass, _ := regexp.MatchString(`^[0-9]{4}-[0-9]{2}-[0-9]{2}$`, name)
pass, _ := regexp.MatchString(`^[0-9]{8}$`, name)
if !pass {
continue
}
tm, err := dateUtils.StrToDate(name)
tm, err := time.Parse("20060102", name)
if err == nil && time.Now().Unix()-tm.Unix() > 7*24*3600 {
fileUtils.RmDir(root + name)
}
......@@ -51,7 +51,7 @@ func ListHistoryLog() (ret []map[string]string) {
for _, dir := range dirs {
dirName := dir.Name()
pass, _ := regexp.MatchString(`^[0-9]{4}-[0-9]{2}-[0-9]{2}$`, dirName)
pass, _ := regexp.MatchString(`^[0-9]{8}$`, dirName)
if !pass {
continue
}
......@@ -64,7 +64,7 @@ func ListHistoryLog() (ret []map[string]string) {
continue
}
item := map[string]string{"name": dirName + constant.PthSep + name}
item := map[string]string{"name": dirName + "-" + name}
ret = append(ret, item)
}
}
......
......@@ -3,8 +3,8 @@ package serverConst
import constant "github.com/easysoft/zentaoatf/src/utils/const"
const (
HeartBeatInterval = 15
CheckUpgradeInterval = 15
HeartBeatInterval = 60
CheckUpgradeInterval = 30
AgentRunTime = 30 * 60
AgentLogDir = "log-agent"
......
......@@ -7,10 +7,16 @@ import (
func DateStr(tm time.Time) string {
return tm.Format("2006-01-02")
}
func DateStrNoSep(tm time.Time) string {
return tm.Format("20060102")
}
func TimeStr(tm time.Time) string {
return tm.Format("15:04:05")
}
func TimeStrNoSep(tm time.Time) string {
return tm.Format("150405")
}
func DateTimeStrFmt(tm time.Time, fm string) string {
return tm.Format(fm)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册