From 912eaeff7dc67caec91885ab562ac2d03d2a3b88 Mon Sep 17 00:00:00 2001 From: enki Date: Mon, 12 May 2025 09:58:04 -0700 Subject: [PATCH] file nuke on post update --- internal/scheduler/scheduler.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/scheduler/scheduler.go b/internal/scheduler/scheduler.go index 98eab64..6348459 100644 --- a/internal/scheduler/scheduler.go +++ b/internal/scheduler/scheduler.go @@ -4,6 +4,7 @@ package scheduler import ( "context" "fmt" + "os" "path/filepath" "sync" "encoding/json" @@ -462,21 +463,23 @@ func (s *Scheduler) ScheduleBot(bot *models.Bot) error { } } - // If posting failed, return without archiving the file + // If posting failed, return without removing the file if postErr != nil { return } - - // Move the file to the archive directory - archivePath := filepath.Join(botArchiveDir, filepath.Base(contentPath)) - if err := utils.MoveFile(contentPath, archivePath); err != nil { - s.logger.Error("Failed to archive file", + + // Delete the file after successful posting to save space + if err := os.Remove(contentPath); err != nil { + s.logger.Error("Failed to delete file after posting", zap.Int64("bot_id", bot.ID), zap.String("file", contentPath), - zap.String("archive", archivePath), zap.Error(err)) return } + + s.logger.Info("Successfully deleted file after posting", + zap.Int64("bot_id", bot.ID), + zap.String("file", contentPath)) } // Schedule the job