link: only write manifest if we have the exclusive lock

Fixes assertion tripping when racing multiple processes that will create
the same static archive.
This commit is contained in:
Andrew Kelley
2023-03-01 22:55:47 -07:00
parent b465dc1234
commit d0f675827c

View File

@@ -1078,9 +1078,11 @@ pub const File = struct {
log.warn("failed to save archive hash digest file: {s}", .{@errorName(err)});
};
man.writeManifest() catch |err| {
log.warn("failed to write cache manifest when archiving: {s}", .{@errorName(err)});
};
if (man.have_exclusive_lock) {
man.writeManifest() catch |err| {
log.warn("failed to write cache manifest when archiving: {s}", .{@errorName(err)});
};
}
base.lock = man.toOwnedLock();
}