From 059da205a4eeeb9d3ec57992c7ffff4c1b331660 Mon Sep 17 00:00:00 2001 From: ajee cai Date: Sun, 26 Jan 2020 16:15:54 +0800 Subject: [PATCH] EOF notified at the beginning of Upload --- upload.go | 3 +++ uploader.go | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/upload.go b/upload.go index 61975bc..e32937c 100644 --- a/upload.go +++ b/upload.go @@ -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 } diff --git a/uploader.go b/uploader.go index 8e39cd7..9653a4f 100644 --- a/uploader.go +++ b/uploader.go @@ -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()