feat: add cmd flags

This commit is contained in:
2026-04-23 21:50:53 +02:00
parent 24be1cedeb
commit 5e2043d54e
8 changed files with 120 additions and 156 deletions
+5 -1
View File
@@ -78,12 +78,14 @@ func watchdog(env bootstrap.Environment, db *gorm.DB) {
readerStream, err := os.Open(fp)
if err != nil {
slog.Error("failed to a reader stream")
continue
}
defer readerStream.Close()
fileData, err := BuildFileRecord(readerStream, filepath.Base(fp), env.ContentDirectory)
if err != nil {
slog.Error("failed to enroll local file into the database", "error", err)
continue
}
if err := RegisterFile(db, fileData); err != nil {
@@ -92,6 +94,7 @@ func watchdog(env bootstrap.Environment, db *gorm.DB) {
} else {
slog.Error("failed to insert filedata to the database", "error", err)
}
continue
}
// to fully finalize the enrollment process, we rename the locally inserted file to a unique filename
@@ -99,7 +102,6 @@ func watchdog(env bootstrap.Environment, db *gorm.DB) {
if err := os.Rename(fp, fileData.FilePath); err != nil {
slog.Error("failed to move the locally inserted file", "error", err)
}
case "strict":
err := utility.RemoveFile(fp)
if err != nil {
@@ -107,6 +109,8 @@ func watchdog(env bootstrap.Environment, db *gorm.DB) {
}
case "dry":
slog.Debug("dry mode enabled, not purging", "filepath", fp)
default:
slog.Warn("unknown watchdog mode", "mode", env.WatchdogSyncMode)
}
}