aboutsummaryrefslogtreecommitdiffstats
path: root/modules/lfs/content_store.go
diff options
context:
space:
mode:
authorKN4CK3R <KN4CK3R@users.noreply.github.com>2021-04-03 14:44:12 +0200
committerGitHub <noreply@github.com>2021-04-03 14:44:12 +0200
commit3cc7d27b6f23628e1ecc9ac1e5f61728be73da76 (patch)
tree819feedf93ec8a60c39c55fb2b75cf268ff0e513 /modules/lfs/content_store.go
parentd0c9b3e20868db5116a0151bc3b40941bc544251 (diff)
downloadgitea-3cc7d27b6f23628e1ecc9ac1e5f61728be73da76.tar.gz
gitea-3cc7d27b6f23628e1ecc9ac1e5f61728be73da76.zip
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>
Diffstat (limited to 'modules/lfs/content_store.go')
-rw-r--r--modules/lfs/content_store.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/lfs/content_store.go b/modules/lfs/content_store.go
index 788ef5b9a6..9473cc35c2 100644
--- a/modules/lfs/content_store.go
+++ b/modules/lfs/content_store.go
@@ -53,6 +53,10 @@ func (s *ContentStore) Get(meta *models.LFSMetaObject, fromByte int64) (io.ReadC
}
if fromByte > 0 {
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{
FromByte: fromByte,
}
@@ -60,6 +64,10 @@ func (s *ContentStore) Get(meta *models.LFSMetaObject, fromByte int64) (io.ReadC
_, err = f.Seek(fromByte, io.SeekStart)
if err != nil {
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