This commit is contained in:
Kovid Goyal 2021-01-01 12:03:09 +05:30
parent 9fbf23fdcc
commit 1cad40e977
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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; in_pos += n; len -= n;
} }
#else #else
const size_t bufsz = 1024 * 1024;
if (!buf) { errno = ENOMEM; return false; }
while (len) { while (len) {
ssize_t amt_read = pread(infd, buf, MIN(len, bufsz), in_pos); ssize_t amt_read = pread(infd, buf, MIN(len, bufsz), in_pos);
if (amt_read < 0) { if (amt_read < 0) {
@ -184,6 +182,7 @@ defrag(DiskCache *self) {
perror("Failed to allocate space for new disk cache file during defrag"); perror("Failed to allocate space for new disk cache file during defrag");
goto cleanup; goto cleanup;
} }
lseek(new_cache_file, 0, SEEK_SET);
#ifndef HAS_SENDFILE #ifndef HAS_SENDFILE
buf = malloc(bufsz); buf = malloc(bufsz);
if (!buf) goto cleanup; if (!buf) goto cleanup;