package database import ( "log/slog" "os" "gorm.io/gorm" ) func watchdog(w string, db *gorm.DB) { slog.Info("performing the watchdog cycle") files, err := GetFiles(db) if err != nil { slog.Error("failed to retrieve the files indexed from the database", "error", err) return } var purgeList []string for _, f := range files { i, err := os.Stat(f.Filepath) if err != nil { if os.IsNotExist(err) { purgeList = append(purgeList, f.Filepath) continue } slog.Warn("stat failed", "file", f.Filepath, "error", err) continue } if i.IsDir() { purgeList = append(purgeList, f.Filepath) // also mark it for purger if its a directory. We do not want that here } } slog.Info("purge list", "files", purgeList) }