1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
| package service
|
| import (
| "os"
| "path"
| "path/filepath"
| "time"
|
| "gat1400Exchange/config"
| "gat1400Exchange/models"
| )
|
| func CleanExpireData() {
| var pos models.Positions
| pos.Clean()
|
| 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
| })
| }
|
|