flush the file index after writing it
diff --git a/lib/fileindex.c b/lib/fileindex.c
index 4562e97..efde946 100644
--- a/lib/fileindex.c
+++ b/lib/fileindex.c
@@ -333,6 +333,9 @@ got_fileindex_write(struct got_fileindex *fileindex, FILE *outfile)
if (n != sizeof(sha1))
return got_ferror(outfile, GOT_ERR_IO);
+ if (fflush(outfile) != 0)
+ return got_error_from_errno();
+
return NULL;
}