MCPcopy
hub / github.com/wavetermdev/waveterm / cleanupOldJobLogs

Function cleanupOldJobLogs

cmd/wsh/cmd/wshcmd-connserver.go:62–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60}
61
62func cleanupOldJobLogs() {
63 jobDir := wavebase.GetRemoteJobLogDir()
64 entries, err := os.ReadDir(jobDir)
65 if err != nil {
66 return
67 }
68
69 cutoffTime := time.Now().Add(-JobLogRetentionTime)
70
71 for _, entry := range entries {
72 if entry.IsDir() {
73 continue
74 }
75
76 name := entry.Name()
77 if !strings.HasSuffix(name, ".log") {
78 continue
79 }
80
81 info, err := entry.Info()
82 if err != nil {
83 continue
84 }
85
86 if info.ModTime().Before(cutoffTime) {
87 filePath := filepath.Join(jobDir, name)
88 err := os.Remove(filePath)
89 if err != nil {
90 log.Printf("error removing old job log file %s: %v", filePath, err)
91 } else {
92 log.Printf("removed old job log file: %s", filePath)
93 }
94 }
95 }
96}
97
98func startJobLogCleanup() {
99 go func() {

Callers 1

startJobLogCleanupFunction · 0.85

Calls 5

GetRemoteJobLogDirFunction · 0.92
InfoMethod · 0.80
ModTimeMethod · 0.80
IsDirMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected