]> git.sesse.net Git - plocate/commitdiff
Fix updatedb writing incomplete .db files under Termux.
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Sat, 11 Nov 2023 23:18:58 +0000 (00:18 +0100)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Sat, 11 Nov 2023 23:18:58 +0000 (00:18 +0100)
Report and patch by Grisha Levit; see

  https://unix.stackexchange.com/questions/739150/var-lib-plocate-plocate-db-has-version-4294967295-expected-0-or-1-please-reb/761248#761248

for the entire story.

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");