From b4a86051e9bf4888fd5d01c12232a26f3874e03b Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期四, 17 十月 2024 21:30:18 +0800 Subject: [PATCH] 完善epc读取楼层 --- service/clean.go | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-) diff --git a/service/clean.go b/service/clean.go index 985a281..f396ece 100644 --- a/service/clean.go +++ b/service/clean.go @@ -1,6 +1,14 @@ package service -import "gat1400Exchange/models" +import ( + "os" + "path" + "path/filepath" + "time" + + "gat1400Exchange/config" + "gat1400Exchange/models" +) func CleanExpireData() { var pos models.Positions @@ -8,4 +16,23 @@ var cache models.Cache cache.Clean() + + if config.ClientConf.UploadType == "url" { + imagePath := path.Join(config.LogConf.Path, "gat1400_face_images") + deleteOldFolders(imagePath) + } +} + +func deleteOldFolders(root string) error { + return filepath.Walk(root, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + if info.IsDir() && time.Now().Sub(info.ModTime()) > 24*time.Hour { + return os.RemoveAll(path) + } + + return nil + }) } -- Gitblit v1.8.0