From 5e56c7f0e801e45526f87a8a6c433868701dcbad Mon Sep 17 00:00:00 2001 From: Justin Harms Date: Fri, 2 Jan 2026 17:34:41 -0600 Subject: [PATCH] Implement file deletion after successful uploads in runner and encoding processes - Added logic to delete files after successful uploads in both runner and encode tasks to prevent duplicate uploads. - Included logging for any errors encountered during file deletion to ensure visibility of issues. --- internal/runner/runner.go | 4 ++++ internal/runner/tasks/encode.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/internal/runner/runner.go b/internal/runner/runner.go index 1d7fa9d..cb7e816 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -289,6 +289,10 @@ func (r *Runner) uploadOutputs(ctx *tasks.Context, job *api.NextJobResponse) err log.Printf("Failed to upload %s: %v", filePath, err) } else { ctx.OutputUploaded(entry.Name()) + // Delete file after successful upload to prevent duplicate uploads + if err := os.Remove(filePath); err != nil { + log.Printf("Warning: Failed to delete file %s after upload: %v", filePath, err) + } } } diff --git a/internal/runner/tasks/encode.go b/internal/runner/tasks/encode.go index 06ebd8d..f0d6984 100644 --- a/internal/runner/tasks/encode.go +++ b/internal/runner/tasks/encode.go @@ -373,6 +373,12 @@ func (p *EncodeProcessor) Process(ctx *Context) error { ctx.Info(fmt.Sprintf("Successfully uploaded %s: %s", strings.ToUpper(outputExt), filepath.Base(outputVideo))) + // Delete file after successful upload to prevent duplicate uploads + if err := os.Remove(outputVideo); err != nil { + log.Printf("Warning: Failed to delete video file %s after upload: %v", outputVideo, err) + ctx.Warn(fmt.Sprintf("Warning: Failed to delete video file after upload: %v", err)) + } + log.Printf("Successfully generated and uploaded %s for job %d: %s", strings.ToUpper(outputExt), ctx.JobID, filepath.Base(outputVideo)) return nil }