From: Steinar H. Gunderson Date: Sat, 11 Nov 2023 23:18:58 +0000 (+0100) Subject: Fix updatedb writing incomplete .db files under Termux. X-Git-Tag: 1.1.20~3 X-Git-Url: https://git.sesse.net/?p=plocate;a=commitdiff_plain;h=994819bafa9d04be683130433a3f57e08e08422c Fix updatedb writing incomplete .db files under Termux. 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. --- diff --git a/database-builder.cpp b/database-builder.cpp index 419e012..f9dfb71 100644 --- a/database-builder.cpp +++ b/database-builder.cpp @@ -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");