Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retries seemed to be causing zero byte files #40

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion core/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,16 @@
if strings.HasSuffix(outputURI, ".ts") || strings.HasSuffix(outputURI, ".mp4") {
// For segments we just write them in one go here and return early.
// (Otherwise the incremental write logic below caused issues with clipping since it results in partial segments being written.)
fileContents, err := io.ReadAll(input)
if err != nil {
return fmt.Errorf("failed to read file")
}

Check warning on line 60 in core/uploader.go

View check run for this annotation

Codecov / codecov/patch

core/uploader.go#L57-L60

Added lines #L57 - L60 were not covered by tests

err = backoff.Retry(func() error {
_, err := session.SaveData(context.Background(), "", input, fields, writeTimeout)
_, err := session.SaveData(context.Background(), "", bytes.NewReader(fileContents), fields, writeTimeout)
if err != nil {
log.Printf("failed upload attempt: %s", err)
}

Check warning on line 66 in core/uploader.go

View check run for this annotation

Codecov / codecov/patch

core/uploader.go#L63-L66

Added lines #L63 - L66 were not covered by tests
return err
}, UploadRetryBackoff())
if err != nil {
Expand Down
Loading