libstore: use makeTemp{,Sibling}Path more
Change-Id: I6a6a69641f9c9d3ab339d25d061dad6cd1f8416d
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user