mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Implement automatic cleanup of unused tags with hourly scheduled deletion
This commit is contained in:
@@ -6,8 +6,24 @@ import (
|
||||
"nysoure/server/model"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Start a goroutine to delete unused tags every hour
|
||||
go func() {
|
||||
// Wait for 1 minute to ensure the database is ready
|
||||
time.Sleep(time.Minute)
|
||||
for {
|
||||
err := dao.ClearUnusedTags()
|
||||
if err != nil {
|
||||
log.Errorf("Failed to clear unused tags: %v", err)
|
||||
}
|
||||
time.Sleep(time.Hour)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func CreateTag(uid uint, name string) (*model.TagView, error) {
|
||||
canUpload, err := checkUserCanUpload(uid)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user