added write error handling

This commit is contained in:
ston1th 2022-03-14 01:16:27 +01:00
commit 2e78593526

View file

@ -85,12 +85,18 @@ func (f *File) readWithoutCache(p []byte) (n int, err error) {
if f.offline { if f.offline {
return 0, io.EOF return 0, io.EOF
} }
log := f.log
n, err = f.f.Read(p) n, err = f.f.Read(p)
if n > 0 {
if n, err := f.md.WriteAt(p[:n], f.offset); err != nil {
log.Error(err, "error writing cache file")
return n, err
}
}
if err != nil { if err != nil {
f.log.Error(err, "error reading source file") log.Error(err, "error reading source file")
return return
} }
f.md.WriteAt(p, f.offset)
f.md.AddChunk(f.offset, n) f.md.AddChunk(f.offset, n)
f.offset += int64(n) f.offset += int64(n)
return return