Fixed delta updates bug wherein updates fail on empty file.

mmap()ing empty files caused EINVAL to be returned and _hashOfFile
would return an incorrect result. This has been rectified.
This commit is contained in:
aidansteele authored and Andy Matuschak committed 2010-08-24 22:58:55 +08:00
1 parent a8f26b16c2
commit e2a59fccb2
1 file changed
+5
+5
View File
@@ -78,6 +78,11 @@ static void _hashOfFile(unsigned char* hash, FTSENT *ent)
}
size_t fileSize = (size_t)ent->fts_statp->st_size;
if (fileSize == 0) {
_hashOfBuffer(hash, NULL, 0);
return;
}
void *buffer = mmap(0, fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
if (buffer == (void*)-1) {
close(fileDescriptor);