From 4651170aa9f292a89f2e780127564ec7a0075a5c Mon Sep 17 00:00:00 2001 From: JungJun Date: Wed, 27 Jul 2022 11:38:49 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20-=20dir=20=EC=82=AD=EC=A0=9C=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- icslog/icslog.go | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/icslog/icslog.go b/icslog/icslog.go index f4d03b9..c1bdfbc 100644 --- a/icslog/icslog.go +++ b/icslog/icslog.go @@ -14,7 +14,6 @@ import ( "gitlab.com/ics_cinnamon/voiceStatistics/icsconf" "gitlab.com/ics_cinnamon/voiceStatistics/icserror" - "gitlab.com/ics_cinnamon/voiceStatistics/icsutil" ) type IcsLog struct { @@ -247,7 +246,6 @@ func (s *IcsLog) DelLog() { return } //var derr *icserror.IcsError = nil - delLogCount := 0 defer func() { if err := recover(); err != nil { @@ -272,32 +270,29 @@ func (s *IcsLog) DelLog() { // s.Printf(LOG_LEVEL_ERROR, -1, " Read Log Dir error - %s \n", rderr) // fmt.Printf("Read Log Dir error - %s", rderr) } else { - var logYYYY, logMM, logDD string + var YYYY, MM, DD string for _, file := range files { - /* - TODO - 1. 로그 파일을 시간으로 변환 - 2. 현재 시간 - 삭제기간 - 3. 둘 시간 차이가 0 이상 나면 삭제대상 - */ - logTime := strings.SplitN(file.Name(), ".", -1)[1] - logYYYY, logMM, logDD = logTime[:4], logTime[4:6], logTime[6:8] - chgLogTime, perr := time.Parse("2006-01-02", fmt.Sprintf("%s%s%s", logYYYY, logMM, logDD)) + _, cerr := strconv.Atoi(file.Name()) + if cerr != nil { + // s.Printf(LOG_LEVEL_ERROR, -1, "Voice Date Parse Error- %s \n", file.Name()) + continue + } + + YYYY, MM, DD = file.Name()[:4], file.Name()[4:6], file.Name()[6:8] + chgVTime, perr := time.Parse("2006-01-02", fmt.Sprintf("%s%s%s", YYYY, MM, DD)) if perr != nil { - // s.Printf(LOG_LEVEL_ERROR, -1, " Log Time Parse error - %s \n", perr) - // fmt.Printf("Log Time Parse error - %s", perr) + // s.Printf(LOG_LEVEL_ERROR, -1, " Voice Time Parse error - %s \n", perr) + // fmt.Printf("Voice Time Parse error - %s\n", perr) } else { - diff := delTime.Sub(chgLogTime) - - // diff > 0 => delete log + diff := delTime.Sub(chgVTime) if diff > 0 { - delResult := icsutil.DeleteFile(s.Path, file.Name()) - if delResult != "" { + delResult := os.RemoveAll(fmt.Sprintf("%s/%s", s.Path, file.Name())) + if delResult != nil { // s.Printf(LOG_LEVEL_ERROR, -1, " Delete File error - %s \n", delResult) + // fmt.Printf("Delete File error [%s] - %s \n", file.Name(), delResult.Error()) } else { - // s.Printf(LOG_LEVEL_INFO, -1, " Delete %s!!!!\n", file.Name()) - // fmt.Printf("Delete %s!!!!\n", file.Name()) - delLogCount += 1 + // s.Printf(LOG_LEVEL_INFO, -1, " Delete %s \n", file.Name()) + // fmt.Printf("Delete %s \n", file.Name()) } } }