mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-17 05:32:41 +00:00
Forget the disk position of a replaced zero length cache entry
This commit is contained in:
parent
cf114eab28
commit
ee56934397
2 changed files with 24 additions and 4 deletions
|
|
@ -422,10 +422,8 @@ static void
|
|||
remove_from_disk(DiskCache *self, CacheValue *s) {
|
||||
if (s->written_to_disk) {
|
||||
s->written_to_disk = false;
|
||||
if (s->data_sz && s->pos_in_cache_file > -1) {
|
||||
add_hole(self, s->pos_in_cache_file, s->data_sz);
|
||||
s->pos_in_cache_file = -1;
|
||||
}
|
||||
if (s->data_sz && s->pos_in_cache_file > -1) add_hole(self, s->pos_in_cache_file, s->data_sz);
|
||||
s->pos_in_cache_file = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -437,6 +437,28 @@ class TestGraphics(BaseTest):
|
|||
for k, v in data.items():
|
||||
self.assertEqual(dc.get(k), v)
|
||||
|
||||
def test_disk_cache_empty_entry_replaced(self):
|
||||
dc = self.create_screen().grman.disk_cache
|
||||
dc.small_hole_threshold = 0
|
||||
dc.defrag_factor = 1000
|
||||
dc.add(b'a', b'A' * 1000)
|
||||
self.assertTrue(dc.wait_for_write())
|
||||
dc.add(b'z', b'')
|
||||
self.assertTrue(dc.wait_for_write())
|
||||
dc.remove(b'a')
|
||||
dc.add(b'c', b'C' * 100)
|
||||
self.assertTrue(dc.wait_for_write())
|
||||
dc.pause_writes()
|
||||
dc.defrag_factor = 2
|
||||
dc.add(b'z', b'Z' * 50)
|
||||
self.assertTrue(dc.wait_until_writes_paused())
|
||||
dc.defrag_factor = 1000
|
||||
self.assertTrue(dc.resume_writes())
|
||||
self.assertTrue(dc.wait_for_write())
|
||||
self.assertEqual(dc.end_of_data_offset(), 150)
|
||||
self.assertEqual(dc.get(b'z'), b'Z' * 50)
|
||||
self.assertEqual(dc.get(b'c'), b'C' * 100)
|
||||
|
||||
def test_disk_cache_encryption_while_being_written(self):
|
||||
s = self.create_screen()
|
||||
dc = s.grman.disk_cache
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue