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

Use new CreateBuildWithUploadUrl endpoint #38

Merged
merged 10 commits into from
Jul 12, 2024
Merged

Conversation

gwprice115
Copy link
Contributor

Switch to using CreateBuildWithUploadUrl

@gwprice115 gwprice115 requested a review from jared-gs July 11, 2024 21:35
Copy link

internal/commands/build.go Show resolved Hide resolved
internal/commands/build.go Show resolved Hide resolved
internal/commands/build.go Outdated Show resolved Hide resolved
internal/commands/build.go Outdated Show resolved Hide resolved
internal/commands/build.go Show resolved Hide resolved
if err != nil {
return err
}
print("\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary with our logger?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea because I have \r in the preceding line, this prevents the next line from mixing characters with the upload progress line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could do something where i'm like "if progress == 100% then use \n otherwise use \r" if you'd prefer

Copy link
Contributor

@jared-gs jared-gs Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be more concise having this line be printed by the processReader.

progressReader := &progressReaderType{
	reader: file,
	total:  fileSize,
	callback: func(percentage float64, loaded int64, total int64, eof bool) {
		if !eof {
			logger.Info(fmt.Sprintf("Upload progress: %.2f%% (%d/%d bytes)\r", percentage, loaded, total))
		} else {
			logger.Info(fmt.Sprintf("Upload complete: %d bytes\n", total))
		}
	},
}

func (pr *progressReaderType) Read(p []byte) (int, error) {
	n, err := pr.reader.Read(p)
	if err != nil && err == io.EOF {
		pr.callback(percentage, pr.read, pr.total, true)
	}
	if n > 0 {
		pr.read += int64(n)
		percentage := float64(pr.read) / float64(pr.total) * 100
		pr.callback(percentage, pr.read, pr.total, false)
	}
	return n, err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh yea i like that

internal/commands/build.go Outdated Show resolved Hide resolved
internal/commands/build.go Outdated Show resolved Hide resolved
gwprice115 and others added 4 commits July 12, 2024 13:23
@gwprice115 gwprice115 merged commit 8a602df into main Jul 12, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants