|
|
@ -17,6 +17,7 @@ |
|
|
|
package cmd |
|
|
|
package cmd |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
|
|
|
|
"fmt" |
|
|
|
"hash" |
|
|
|
"hash" |
|
|
|
"io" |
|
|
|
"io" |
|
|
|
|
|
|
|
|
|
|
@ -35,12 +36,12 @@ type wholeBitrotWriter struct { |
|
|
|
func (b *wholeBitrotWriter) Write(p []byte) (int, error) { |
|
|
|
func (b *wholeBitrotWriter) Write(p []byte) (int, error) { |
|
|
|
err := b.disk.AppendFile(b.volume, b.filePath, p) |
|
|
|
err := b.disk.AppendFile(b.volume, b.filePath, p) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
logger.LogIf(GlobalContext, err) |
|
|
|
logger.LogIf(GlobalContext, fmt.Errorf("Disk: %s returned %w", b.disk, err)) |
|
|
|
return 0, err |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
} |
|
|
|
_, err = b.Hash.Write(p) |
|
|
|
_, err = b.Hash.Write(p) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
logger.LogIf(GlobalContext, err) |
|
|
|
logger.LogIf(GlobalContext, fmt.Errorf("Disk: %s returned %w", b.disk, err)) |
|
|
|
return 0, err |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
} |
|
|
|
return len(p), nil |
|
|
|
return len(p), nil |
|
|
@ -69,9 +70,7 @@ func (b *wholeBitrotReader) ReadAt(buf []byte, offset int64) (n int, err error) |
|
|
|
if b.buf == nil { |
|
|
|
if b.buf == nil { |
|
|
|
b.buf = make([]byte, b.tillOffset-offset) |
|
|
|
b.buf = make([]byte, b.tillOffset-offset) |
|
|
|
if _, err := b.disk.ReadFile(b.volume, b.filePath, offset, b.buf, b.verifier); err != nil { |
|
|
|
if _, err := b.disk.ReadFile(b.volume, b.filePath, offset, b.buf, b.verifier); err != nil { |
|
|
|
ctx := GlobalContext |
|
|
|
logger.LogIf(GlobalContext, fmt.Errorf("Disk: %s returned %w", b.disk, err)) |
|
|
|
logger.GetReqInfo(ctx).AppendTags("disk", b.disk.String()) |
|
|
|
|
|
|
|
logger.LogIf(ctx, err) |
|
|
|
|
|
|
|
return 0, err |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|