更新 main.go

This commit is contained in:
XOF
2025-12-17 01:00:25 +08:00
parent bcde4b99a7
commit 7fa042156a

View File

@@ -56,6 +56,10 @@ func main() {
os.MkdirAll(downloadDir, 0755)
log.Printf("Auth enabled: %v, Port: %s, Keep versions: %d", authEnabled, port, keepVersions)
// 启动时立即检查一次
log.Println("Performing initial check...")
checkAndDownload()
go monitor()
http.HandleFunc("/", authMiddleware(serveIndex))
@@ -115,7 +119,7 @@ func checkAndDownload() {
return
}
log.Printf("Downloaded: %s", filename)
log.Printf("Downloaded: %s (%.2f MB)", filename, float64(len(data))/1024/1024)
cleanupOldVersions()
}
@@ -143,6 +147,7 @@ func cleanupOldVersions() {
for i := keepVersions; i < len(versions); i++ {
os.Remove(filepath.Join(downloadDir, versions[i].Filename))
log.Printf("Removed old version: %s", versions[i].Filename)
}
}