diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2015-06-10 16:43:48 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2015-06-10 16:43:48 -0400 |
commit | 3e8c5e45cbf4f52b1100e7ae9f5cc229882b6f4d (patch) | |
tree | 8cd199eaf9dc2ec4db44e743176ef0e744315bbe /src/indexer.c | |
parent | 7f8cd672a13b317aea6aebbf15af2e94a3c6a47c (diff) | |
parent | aa57231fca5897c0779d5bcfc5d9183b454792eb (diff) | |
download | libgit2-3e8c5e45cbf4f52b1100e7ae9f5cc229882b6f4d.tar.gz |
Merge pull request #3174 from libgit2/cmn/idx-fill-hole
indexer: use lseek to extend the packfile
Diffstat (limited to 'src/indexer.c')
-rw-r--r-- | src/indexer.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/indexer.c b/src/indexer.c index ef2ac3cba..512addf48 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -478,13 +478,14 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t static int append_to_pack(git_indexer *idx, const void *data, size_t size) { git_off_t current_size = idx->pack->mwf.size; + int fd = idx->pack->mwf.fd; if (!size) return 0; - /* add the extra space we need at the end */ - if (p_ftruncate(idx->pack->mwf.fd, current_size + size) < 0) { - giterr_set(GITERR_OS, "Failed to increase size of pack file '%s'", idx->pack->pack_name); + if (p_lseek(fd, current_size + size - 1, SEEK_SET) < 0 || + p_write(idx->pack->mwf.fd, data, 1) < 0) { + giterr_set(GITERR_OS, "cannot extend packfile '%s'", idx->pack->pack_name); return -1; } |