Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit dc551ca

Browse files
committed
Merge pull request ninja-build#556 from nico/unlink
Make sure that recompaction writes a pristine new depslog.
2 parents 931b19d + 92f48ca commit dc551ca

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/deps_log.cc

+5
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ bool DepsLog::Recompact(const string& path, string* err) {
244244
printf("Recompacting deps...\n");
245245

246246
string temp_path = path + ".recompact";
247+
248+
// OpenForWrite() opens for append. Make sure it's not appending to a
249+
// left-over file from a previous recompaction attempt that crashed somehow.
250+
unlink(temp_path.c_str());
251+
247252
DepsLog new_log;
248253
if (!new_log.OpenForWrite(temp_path, err))
249254
return false;

0 commit comments

Comments
 (0)