fix preload alignment for custom buffer sizes
This commit is contained in:
parent
880e2f06b3
commit
cb7f2dee54
6 changed files with 12 additions and 46 deletions
|
|
@ -43,6 +43,9 @@ func (p *preload) Read(data []byte) (n int, err error) {
|
|||
return
|
||||
}
|
||||
n, err = p.f.readToCache(data)
|
||||
if n < len(data) {
|
||||
_, err = p.f.Seek(p.f.offset, io.SeekStart)
|
||||
}
|
||||
p.written++
|
||||
return
|
||||
}
|
||||
|
|
@ -60,11 +63,6 @@ func (f *File) Preload(ctx context.Context, unlock func()) {
|
|||
return
|
||||
}
|
||||
|
||||
// TODO
|
||||
//fi, _ := f.Stat()
|
||||
//s := fi.Size()
|
||||
//log.V(2).Info("preload started", "size", s, "crypto.Size", crypto.Size(s), "crypto.RealSize", crypto.RealSize(crypto.Size(s)))
|
||||
|
||||
log.V(2).Info("preload started")
|
||||
p := &preload{f: f, ctx: ctx}
|
||||
_, err := io.Copy(Discard, p)
|
||||
|
|
@ -128,9 +126,9 @@ func (f *File) readToCache(p []byte) (n int, err error) {
|
|||
log := f.log
|
||||
n, err = f.readSource(p)
|
||||
if n > 0 {
|
||||
if n, err := f.md.WriteAt(p[:n], f.offset); err != nil {
|
||||
if n, err = f.md.WriteAt(p[:n], f.offset); err != nil {
|
||||
log.Error(err, "error writing cache file")
|
||||
return n, err
|
||||
return
|
||||
}
|
||||
}
|
||||
if err != nil && err != io.EOF {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue