libstore: use makeTemp{,Sibling}Path more

Change-Id: I6a6a69641f9c9d3ab339d25d061dad6cd1f8416d
This commit is contained in:
Emily
2025-08-18 09:27:31 +00:00
committed by emilazy
parent 24ccf500d1
commit cad304420f
3 changed files with 5 additions and 17 deletions
+1 -2
View File
@@ -69,8 +69,7 @@ protected:
) override
try {
auto path2 = binaryCacheDir + "/" + path;
static std::atomic<int> counter{0};
Path tmp = fmt("%s.tmp.%d.%d", path2, getpid(), ++counter);
Path tmp = makeTempPath(path2);
AutoDelete del(tmp, false);
StreamToSourceAdapter source(istream);
writeFile(tmp, source);
+1 -1
View File
@@ -1734,7 +1734,7 @@ try {
createDirs(dirOf(logPath));
auto tmpFile = fmt("%s.tmp.%d", logPath, getpid());
auto tmpFile = makeTempSiblingPath(logPath);
writeFile(tmpFile, compress("bzip2", log));
+3 -14
View File
@@ -711,20 +711,9 @@ void createSymlink(const Path & target, const Path & link)
void replaceSymlink(const Path & target, const Path & link)
{
for (unsigned int n = 0; true; n++) {
Path tmp = canonPath(fmt("%s/.%d_%s", dirOf(link), n, baseNameOf(link)));
try {
createSymlink(target, tmp);
} catch (SysError & e) {
if (e.errNo == EEXIST) continue;
throw;
}
renameFile(tmp, link);
break;
}
Path tmp = canonPath(makeTempSiblingPath(link));
createSymlink(target, tmp);
renameFile(tmp, link);
}
void setWriteTime(const fs::path & p, const struct stat & st)