forked from gitea/gitea
Close file on invalid range (#15166)
* Close file on invalid range. * Close on seek error Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
d0c9b3e208
commit
3cc7d27b6f
|
@ -53,6 +53,10 @@ func (s *ContentStore) Get(meta *models.LFSMetaObject, fromByte int64) (io.ReadC
|
||||||
}
|
}
|
||||||
if fromByte > 0 {
|
if fromByte > 0 {
|
||||||
if fromByte >= meta.Size {
|
if fromByte >= meta.Size {
|
||||||
|
err = f.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Whilst trying to read LFS OID[%s]: Unable to close Error: %v", meta.Oid, err)
|
||||||
|
}
|
||||||
return nil, ErrRangeNotSatisfiable{
|
return nil, ErrRangeNotSatisfiable{
|
||||||
FromByte: fromByte,
|
FromByte: fromByte,
|
||||||
}
|
}
|
||||||
|
@ -60,6 +64,10 @@ func (s *ContentStore) Get(meta *models.LFSMetaObject, fromByte int64) (io.ReadC
|
||||||
_, err = f.Seek(fromByte, io.SeekStart)
|
_, err = f.Seek(fromByte, io.SeekStart)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Whilst trying to read LFS OID[%s]: Unable to seek to %d Error: %v", meta.Oid, fromByte, err)
|
log.Error("Whilst trying to read LFS OID[%s]: Unable to seek to %d Error: %v", meta.Oid, fromByte, err)
|
||||||
|
errClose := f.Close()
|
||||||
|
if errClose != nil {
|
||||||
|
log.Error("Whilst trying to read LFS OID[%s]: Unable to close Error: %v", meta.Oid, errClose)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return f, err
|
return f, err
|
||||||
|
|
Loading…
Reference in New Issue