Revert "libstore: simplify makeTemp{,Sibling}Path callers"

Revert submission 3850

Reason for revert: caused multiple regressions noticed in https://git.lix.systems/lix-project/lix/issues/975 and https://git.lix.systems/lix-project/lix/issues/966 (suspected).

Root cause analysis has not been done yet and this breaks Lix on Darwin on HEAD.

Reverted changes: /q/submissionid:3850

Change-Id: I410046be0ed84e84d1530748d29383489e36c72c
This commit is contained in:
Raito Bezarius
2025-08-21 14:37:46 +00:00
parent ca3328dac0
commit 7c03f42759
3 changed files with 9 additions and 3 deletions
+5 -1
View File
@@ -761,7 +761,11 @@ void replaceValidPath(const Path & storePath, const Path & tmpPath)
we're repairing (say) Glibc, we end up with a broken system. */
Path oldPath;
if (pathExists(storePath)) {
oldPath = makeTempSiblingPath(storePath);
do {
oldPath = makeTempSiblingPath(storePath);
// store paths are often directories so we can't just unlink() it
// let's make sure the path doesn't exist before we try to use it
} while (pathExists(oldPath));
movePath(storePath, oldPath);
}
+2 -1
View File
@@ -42,6 +42,7 @@ static void makeSymlink(const Path & link, const Path & target)
/* Create the new symlink. */
Path tempLink = makeTempPath(link);
unlink(tempLink.c_str()); // just in case; ignore errors
createSymlink(target, tempLink);
/* Atomically replace the old one. */
@@ -96,7 +97,7 @@ void LocalStore::createTempRootsFile()
/* Create the temporary roots file for this process. */
while (true) {
auto tmp = makeTempPath(fnTempRoots);
auto tmp = makeTempPath(fnTempRoots, ".tmp");
AutoCloseFD fd{open(tmp.c_str(), O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC, 0600)};
if (!fd && errno != EEXIST) {
throw SysError("opening lock file '%1%'", tmp);
+2 -1
View File
@@ -218,7 +218,8 @@ void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats,
its timestamp back to 0. */
MakeReadOnly makeReadOnly(mustToggle ? dirOfPath : "");
Path tempLink = makeTempPath(config().realStoreDir + "/");
Path tempLink = makeTempPath(config().realStoreDir, "/.tmp-link");
unlink(tempLink.c_str()); // just in case; ignore errors
if (link(linkPath.c_str(), tempLink.c_str()) == -1) {
if (errno == EMLINK) {