Merge pull request 'Implement file deletion after successful uploads in runner and encoding processes' (#3) from fix-uploads into master
Reviewed-on: #3
This commit is contained in:
@@ -10,6 +10,8 @@ jobs:
|
|||||||
- uses: actions/setup-go@main
|
- uses: actions/setup-go@main
|
||||||
with:
|
with:
|
||||||
go-version-file: 'go.mod'
|
go-version-file: 'go.mod'
|
||||||
- run: go mod tidy
|
- uses: FedericoCarboni/setup-ffmpeg@v3
|
||||||
|
- run: go mod tidy
|
||||||
|
- run: cd web && npm install && npm run build
|
||||||
- run: go build ./...
|
- run: go build ./...
|
||||||
- run: go test -race -v -shuffle=on ./...
|
- run: go test -race -v -shuffle=on ./...
|
||||||
@@ -289,6 +289,10 @@ func (r *Runner) uploadOutputs(ctx *tasks.Context, job *api.NextJobResponse) err
|
|||||||
log.Printf("Failed to upload %s: %v", filePath, err)
|
log.Printf("Failed to upload %s: %v", filePath, err)
|
||||||
} else {
|
} else {
|
||||||
ctx.OutputUploaded(entry.Name())
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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)))
|
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))
|
log.Printf("Successfully generated and uploaded %s for job %d: %s", strings.ToUpper(outputExt), ctx.JobID, filepath.Base(outputVideo))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user