From 7d685fc98b3898ccfe3272cb98dd556189eb4628 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jul 2024 06:22:54 +0530 Subject: [PATCH] Getting size of cache file should not change its position --- kitty/disk-cache.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kitty/disk-cache.c b/kitty/disk-cache.c index cd5c35ad4..9f6993252 100644 --- a/kitty/disk-cache.c +++ b/kitty/disk-cache.c @@ -122,7 +122,10 @@ open_cache_file(const char *cache_path) { static off_t size_of_cache_file(DiskCache *self) { - return lseek(self->cache_file_fd, 0, SEEK_END); + off_t pos = lseek(self->cache_file_fd, 0, SEEK_CUR); + off_t ans = lseek(self->cache_file_fd, 0, SEEK_END); + lseek(self->cache_file_fd, pos, SEEK_SET); + return ans; } size_t