Compare commits

..

No commits in common. "c06b046df5831c26e97a42bf44ca5b6220e00c0e" and "05cc242ee58d4d06c67e4b9d1913ae15a495098e" have entirely different histories.

View File

@ -4,7 +4,6 @@ package scheduler
import ( import (
"context" "context"
"fmt" "fmt"
"os"
"path/filepath" "path/filepath"
"sync" "sync"
"encoding/json" "encoding/json"
@ -463,23 +462,21 @@ func (s *Scheduler) ScheduleBot(bot *models.Bot) error {
} }
} }
// If posting failed, return without removing the file // If posting failed, return without archiving the file
if postErr != nil { if postErr != nil {
return return
} }
// Delete the file after successful posting to save space // Move the file to the archive directory
if err := os.Remove(contentPath); err != nil { archivePath := filepath.Join(botArchiveDir, filepath.Base(contentPath))
s.logger.Error("Failed to delete file after posting", if err := utils.MoveFile(contentPath, archivePath); err != nil {
s.logger.Error("Failed to archive file",
zap.Int64("bot_id", bot.ID), zap.Int64("bot_id", bot.ID),
zap.String("file", contentPath), zap.String("file", contentPath),
zap.String("archive", archivePath),
zap.Error(err)) zap.Error(err))
return return
} }
s.logger.Info("Successfully deleted file after posting",
zap.Int64("bot_id", bot.ID),
zap.String("file", contentPath))
} }
// Schedule the job // Schedule the job