forked from TrueCloudLab/distribution
Loop bug fix
This commit is contained in:
parent
a952c77b4a
commit
576495ec3e
1 changed files with 11 additions and 8 deletions
|
@ -228,11 +228,12 @@ func (d *Driver) WriteStream(path string, offset int64, reader io.Reader) (total
|
|||
for int64(bytesRead) < total {
|
||||
//The loop should very rarely enter a second iteration
|
||||
nn, err := io.ReadFull(current, buf[bytesRead:total])
|
||||
if err != nil && err != io.ErrUnexpectedEOF && err != io.EOF {
|
||||
bytesRead += nn
|
||||
if err != nil {
|
||||
// If you can't read the total contents, this means you lack access to the current file
|
||||
return err
|
||||
}
|
||||
|
||||
bytesRead += nn
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -245,9 +246,13 @@ func (d *Driver) WriteStream(path string, offset int64, reader io.Reader) (total
|
|||
totalRead += int64(nn)
|
||||
bytesRead += nn
|
||||
|
||||
if err != nil && err != io.ErrUnexpectedEOF && err != io.EOF {
|
||||
if err != nil {
|
||||
if err != io.ErrUnexpectedEOF && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
part, err = multi.PutPart(int(partNumber), bytes.NewReader(buf[0:int64(bytesRead)+from]))
|
||||
|
@ -304,8 +309,7 @@ func (d *Driver) WriteStream(path string, offset int64, reader io.Reader) (total
|
|||
for from+int64(bytesRead) < to {
|
||||
nn, err := io.ReadFull(bytes.NewReader(zeroBuf), buf[from+int64(bytesRead):to])
|
||||
bytesRead += nn
|
||||
|
||||
if err != nil && err != io.ErrUnexpectedEOF && err != io.EOF {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -331,8 +335,7 @@ func (d *Driver) WriteStream(path string, offset int64, reader io.Reader) (total
|
|||
for from+bytesRead64+int64(bytesRead) < to {
|
||||
nn, err := io.ReadFull(bytes.NewReader(zeroBuf), buf[0+bytesRead:(to-from)%chunkSize])
|
||||
bytesRead64 += int64(nn)
|
||||
|
||||
if err != nil && err != io.ErrUnexpectedEOF && err != io.EOF {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue