make linter happy
Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
parent
49543518f0
commit
5b77b2f27d
4 changed files with 30 additions and 17 deletions
|
@ -6,15 +6,25 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// ErrChuckSize is returned when the chunk size is zero
|
||||
ErrChuckSize = errors.New("tus chunk size must be greater than zero")
|
||||
// ErrNilConfig is returned when the logger is nil
|
||||
ErrNilLogger = errors.New("tus logger can't be nil")
|
||||
ErrNilStore = errors.New("tus store can't be nil if Resume is enable")
|
||||
// ErrNilStore is returned when the store is nil
|
||||
ErrNilStore = errors.New("tus store can't be nil if resume is enable")
|
||||
// ErrNilUpload is returned when the upload is nil
|
||||
ErrNilUpload = errors.New("tus upload can't be nil")
|
||||
// ErrLargeUpload is returned when the upload body is to large
|
||||
ErrLargeUpload = errors.New("tus upload body is to large")
|
||||
// ErrVersionMismatch is returned when the tus protocol version is mismatching
|
||||
ErrVersionMismatch = errors.New("tus protocol version mismatch")
|
||||
// ErrOffsetMismatch is returned when the tus upload offset is mismatching
|
||||
ErrOffsetMismatch = errors.New("tus upload offset mismatch")
|
||||
// ErrUploadNotFound is returned when the tus upload is not found
|
||||
ErrUploadNotFound = errors.New("tus upload not found")
|
||||
// ErrResumeNotEnabled is returned when the tus resuming is not enabled
|
||||
ErrResumeNotEnabled = errors.New("tus resuming not enabled")
|
||||
// ErrFingerprintNotSet is returned when the tus fingerprint is not set
|
||||
ErrFingerprintNotSet = errors.New("tus fingerprint not set")
|
||||
)
|
||||
|
||||
|
|
|
@ -26,22 +26,22 @@ func (u *Upload) updateProgress(offset int64) {
|
|||
u.offset = offset
|
||||
}
|
||||
|
||||
// Returns whether this upload is finished or not.
|
||||
// Finished returns whether this upload is finished or not.
|
||||
func (u *Upload) Finished() bool {
|
||||
return u.offset >= u.size
|
||||
}
|
||||
|
||||
// Returns the progress in a percentage.
|
||||
// Progress returns the progress in a percentage.
|
||||
func (u *Upload) Progress() int64 {
|
||||
return (u.offset * 100) / u.size
|
||||
}
|
||||
|
||||
// Returns the current upload offset.
|
||||
// Offset returns the current upload offset.
|
||||
func (u *Upload) Offset() int64 {
|
||||
return u.offset
|
||||
}
|
||||
|
||||
// Returns the size of the upload body.
|
||||
// Size returns the size of the upload body.
|
||||
func (u *Upload) Size() int64 {
|
||||
return u.size
|
||||
}
|
||||
|
@ -67,7 +67,10 @@ func NewUpload(reader io.Reader, size int64, metadata Metadata, fingerprint stri
|
|||
|
||||
if !ok {
|
||||
buf := new(bytes.Buffer)
|
||||
buf.ReadFrom(reader)
|
||||
_, err := buf.ReadFrom(reader)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
stream = bytes.NewReader(buf.Bytes())
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ type Uploader struct {
|
|||
overridePatchMethod bool
|
||||
}
|
||||
|
||||
// Subscribes to progress updates.
|
||||
// NotifyUploadProgress subscribes to progress updates.
|
||||
func (u *Uploader) NotifyUploadProgress(c chan Upload) {
|
||||
u.uploadSubs = append(u.uploadSubs, c)
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ func (u *Uploader) uploadChunk(ctx context.Context, body io.Reader, size int64,
|
|||
|
||||
// Upload uploads the entire body to the server.
|
||||
func (u *Uploader) Upload(ctx context.Context, options ...fs.OpenOption) error {
|
||||
var cnt int = 1
|
||||
cnt := 1
|
||||
|
||||
fs.Debug(u.fs, "Uploaded starts")
|
||||
for u.offset < u.upload.size && !u.aborted {
|
||||
|
|
|
@ -64,7 +64,7 @@ func (f *Fs) shouldRetryCreateUpload(ctx context.Context, resp *http.Response, e
|
|||
return f.shouldRetry(ctx, resp, err)
|
||||
}
|
||||
|
||||
// CreateUpload creates a new upload to the server.
|
||||
// CreateUploader creates a new upload to the server.
|
||||
func (o *Object) CreateUploader(ctx context.Context, u *Upload, options ...fs.OpenOption) (*Uploader, error) {
|
||||
if u == nil {
|
||||
return nil, ErrNilUpload
|
||||
|
|
Loading…
Reference in a new issue