diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2018-01-16 14:25:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-16 14:25:37 +0100 |
commit | e9247ce9c5ce12126f646ca3ddf0066e4829bd14 (patch) | |
tree | 571dc4b1531475c8dd0cf8e7492b2a58eb5a126f /plumbing/cache/object_lru.go | |
parent | 4d43799bf111a66b204312c79f1d0dd0d96108b1 (diff) | |
parent | 0f6c06db068acb7a8eab639df20b72fa717232c8 (diff) | |
download | go-git-e9247ce9c5ce12126f646ca3ddf0066e4829bd14.tar.gz |
Merge pull request #720 from jfontan/improvement/cache-delete-more-than-one-objectv4.1.0
plumbing: cache, modify cache to delete more than one item to free space
Diffstat (limited to 'plumbing/cache/object_lru.go')
-rw-r--r-- | plumbing/cache/object_lru.go | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/plumbing/cache/object_lru.go b/plumbing/cache/object_lru.go index d99a5c9..0494539 100644 --- a/plumbing/cache/object_lru.go +++ b/plumbing/cache/object_lru.go @@ -51,11 +51,11 @@ func (c *ObjectLRU) Put(obj plumbing.EncodedObject) { objSize := FileSize(obj.Size()) - if objSize >= c.MaxSize { + if objSize > c.MaxSize { return } - if c.actualSize+objSize > c.MaxSize { + for c.actualSize+objSize > c.MaxSize { last := c.ll.Back() lastObj := last.Value.(plumbing.EncodedObject) lastSize := FileSize(lastObj.Size()) @@ -63,10 +63,6 @@ func (c *ObjectLRU) Put(obj plumbing.EncodedObject) { c.ll.Remove(last) delete(c.cache, lastObj.Hash()) c.actualSize -= lastSize - - if c.actualSize+objSize > c.MaxSize { - return - } } ee := c.ll.PushFront(obj) |