Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ func (u *Upload) Finished() bool {

// Returns the progress in a percentage.
func (u *Upload) Progress() int64 {
if u.size == 0 {
return 1
}
return (u.offset * 100) / u.size
}

Expand Down
6 changes: 6 additions & 0 deletions uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ func (u *Uploader) Offset() int64 {

// Upload uploads the entire body to the server.
func (u *Uploader) Upload() error {
if u.offset == u.upload.size {
u.upload.updateProgress(u.offset)
u.notifyChan <- true
return nil
}

for u.offset < u.upload.size && !u.aborted {
err := u.UploadChunck()

Expand Down