From 1cad40e9775f2b58e491804f3e8fe254e03f51bd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Jan 2021 12:03:09 +0530 Subject: [PATCH] ... --- kitty/disk-cache.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kitty/disk-cache.c b/kitty/disk-cache.c index 92c2c8510..93c4fa6cb 100644 --- a/kitty/disk-cache.c +++ b/kitty/disk-cache.c @@ -108,8 +108,6 @@ copy_between_files(int infd, int outfd, off_t in_pos, size_t len, uint8_t *buf, in_pos += n; len -= n; } #else - const size_t bufsz = 1024 * 1024; - if (!buf) { errno = ENOMEM; return false; } while (len) { ssize_t amt_read = pread(infd, buf, MIN(len, bufsz), in_pos); if (amt_read < 0) { @@ -184,6 +182,7 @@ defrag(DiskCache *self) { perror("Failed to allocate space for new disk cache file during defrag"); goto cleanup; } + lseek(new_cache_file, 0, SEEK_SET); #ifndef HAS_SENDFILE buf = malloc(bufsz); if (!buf) goto cleanup;