mount: shortcut when there is only one chunk

This commit is contained in:
Chris Lu
2020-10-20 23:48:29 -07:00
parent f64252023e
commit c31b254248
3 changed files with 28 additions and 5 deletions

View File

@@ -76,10 +76,15 @@ func Upload(uploadUrl string, filename string, cipher bool, reader io.Reader, is
}
func doUpload(uploadUrl string, filename string, cipher bool, reader io.Reader, isInputCompressed bool, mtype string, pairMap map[string]string, jwt security.EncodedJwt) (uploadResult *UploadResult, err error, data []byte) {
data, err = ioutil.ReadAll(reader)
if err != nil {
err = fmt.Errorf("read input: %v", err)
return
bytesReader, ok := reader.(*util.BytesReader)
if ok {
data = bytesReader.Bytes
} else {
data, err = ioutil.ReadAll(reader)
if err != nil {
err = fmt.Errorf("read input: %v", err)
return
}
}
uploadResult, uploadErr := retriedUploadData(uploadUrl, filename, cipher, data, isInputCompressed, mtype, pairMap, jwt)
return uploadResult, uploadErr, data