|
|
@ -418,18 +418,19 @@ func (c *diskCache) bitrotWriteToCache(ctx context.Context, cachePath string, re |
|
|
|
bufp := c.pool.Get().(*[]byte) |
|
|
|
bufp := c.pool.Get().(*[]byte) |
|
|
|
defer c.pool.Put(bufp) |
|
|
|
defer c.pool.Put(bufp) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var n int |
|
|
|
for { |
|
|
|
for { |
|
|
|
n, err := io.ReadFull(reader, *bufp) |
|
|
|
n, err = io.ReadFull(reader, *bufp) |
|
|
|
if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF && err != io.ErrClosedPipe { |
|
|
|
if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { |
|
|
|
return 0, err |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
} |
|
|
|
eof := err == io.EOF || err == io.ErrUnexpectedEOF || err == io.ErrClosedPipe |
|
|
|
eof := err == io.EOF || err == io.ErrUnexpectedEOF |
|
|
|
if n == 0 && size != 0 { |
|
|
|
if n == 0 && size != 0 { |
|
|
|
// Reached EOF, nothing more to be done.
|
|
|
|
// Reached EOF, nothing more to be done.
|
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
h.Reset() |
|
|
|
h.Reset() |
|
|
|
if _, err := h.Write((*bufp)[:n]); err != nil { |
|
|
|
if _, err = h.Write((*bufp)[:n]); err != nil { |
|
|
|
return 0, err |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
} |
|
|
|
hashBytes := h.Sum(nil) |
|
|
|
hashBytes := h.Sum(nil) |
|
|
@ -522,7 +523,9 @@ func (c *diskCache) Put(ctx context.Context, bucket, object string, data io.Read |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if actualSize != uint64(n) { |
|
|
|
|
|
|
|
return IncompleteBody{} |
|
|
|
|
|
|
|
} |
|
|
|
return c.saveMetadata(ctx, bucket, object, metadata, n) |
|
|
|
return c.saveMetadata(ctx, bucket, object, metadata, n) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|