forked from TrueCloudLab/distribution
Do not read segment if no padding is necessary
Signed-off-by: Sylvain Baubeau <sbaubeau@redhat.com>
This commit is contained in:
parent
3242378e1b
commit
f21cbcebc6
1 changed files with 7 additions and 5 deletions
|
@ -295,7 +295,7 @@ func (d *driver) WriteStream(ctx context.Context, path string, offset int64, rea
|
||||||
|
|
||||||
cursor = currentLength
|
cursor = currentLength
|
||||||
paddingReader = bytes.NewReader(zeroBuf)
|
paddingReader = bytes.NewReader(zeroBuf)
|
||||||
} else {
|
} else if offset-cursor > 0 {
|
||||||
// Offset is inside the current segment : we need to read the
|
// Offset is inside the current segment : we need to read the
|
||||||
// data from the beginning of the segment to offset
|
// data from the beginning of the segment to offset
|
||||||
file, _, err := d.Conn.ObjectOpen(d.Container, getSegment(), false, nil)
|
file, _, err := d.Conn.ObjectOpen(d.Container, getSegment(), false, nil)
|
||||||
|
@ -307,10 +307,12 @@ func (d *driver) WriteStream(ctx context.Context, path string, offset int64, rea
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
multi = io.MultiReader(
|
readers := []io.Reader{}
|
||||||
io.LimitReader(paddingReader, offset-cursor),
|
if paddingReader != nil {
|
||||||
io.LimitReader(reader, chunkSize-(offset-cursor)),
|
readers = append(readers, io.LimitReader(paddingReader, offset-cursor))
|
||||||
)
|
}
|
||||||
|
readers = append(readers, io.LimitReader(reader, chunkSize-(offset-cursor)))
|
||||||
|
multi = io.MultiReader(readers...)
|
||||||
|
|
||||||
writeSegment := func(segment string) (finished bool, bytesRead int64, err error) {
|
writeSegment := func(segment string) (finished bool, bytesRead int64, err error) {
|
||||||
currentSegment, err := d.Conn.ObjectCreate(d.Container, segment, false, "", d.getContentType(), nil)
|
currentSegment, err := d.Conn.ObjectCreate(d.Container, segment, false, "", d.getContentType(), nil)
|
||||||
|
|
Loading…
Reference in a new issue