]> git.sesse.net Git - plocate/blobdiff - database-builder.cpp
Fix updatedb writing incomplete .db files under Termux.
[plocate] / database-builder.cpp
index 419e012ca94c2625471680de17b67f07716ecec8..f9dfb715391b3be7c4c521710d48f86b3b10795b 100644 (file)
@@ -683,6 +683,10 @@ void DatabaseBuilder::finish_corpus()
        fseek(outfp, 0, SEEK_SET);
        fwrite(&hdr, sizeof(hdr), 1, outfp);
 
+       // This is needed on systems that simulate linkat() by copying
+       // the contents of the file instead of linking.
+       fflush(outfp);
+
        if (!temp_filename.empty()) {
                if (rename(temp_filename.c_str(), outfile.c_str()) == -1) {
                        perror("rename");