Skip to content

Commit

Permalink
Bug fix: Fix peek when value is so large that a file is used (#288)
Browse files Browse the repository at this point in the history
Error caused by copy/paste from pull().
  • Loading branch information
grantjenks authored Aug 31, 2023
1 parent 4d30686 commit 17a5f42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 0 additions & 3 deletions diskcache/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1703,9 +1703,6 @@ def peek(
except IOError:
# Key was deleted before we could retrieve result.
continue
finally:
if name is not None:
self._disk.remove(name)
break

if expire_time and tag:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_deque.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,13 @@ def test_rotate_indexerror_negative(deque):

with mock.patch.object(deque, '_cache', cache):
deque.rotate(-1)


def test_peek(deque):
value = b'x' * 100_000
deque.append(value)
assert len(deque) == 1
assert deque.peek() == value
assert len(deque) == 1
assert deque.peek() == value
assert len(deque) == 1

0 comments on commit 17a5f42

Please sign in to comment.