AutoDelete: Add default constructor with deletion disabled
This commit is contained in:
parent
4390142315
commit
58d2fac91d
|
@ -2534,7 +2534,7 @@ void DerivationGoal::runChild()
|
||||||
|
|
||||||
Path sandboxFile = drvPath + ".sb";
|
Path sandboxFile = drvPath + ".sb";
|
||||||
if (pathExists(sandboxFile)) deletePath(sandboxFile);
|
if (pathExists(sandboxFile)) deletePath(sandboxFile);
|
||||||
autoDelSandbox = AutoDelete(sandboxFile);
|
autoDelSandbox.reset(sandboxFile, false);
|
||||||
|
|
||||||
writeFile(sandboxFile, sandboxProfile);
|
writeFile(sandboxFile, sandboxProfile);
|
||||||
|
|
||||||
|
|
|
@ -599,6 +599,8 @@ string drainFD(int fd)
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
AutoDelete::AutoDelete() : del{false} {}
|
||||||
|
|
||||||
AutoDelete::AutoDelete(const string & p, bool recursive) : path(p)
|
AutoDelete::AutoDelete(const string & p, bool recursive) : path(p)
|
||||||
{
|
{
|
||||||
del = true;
|
del = true;
|
||||||
|
@ -626,6 +628,12 @@ void AutoDelete::cancel()
|
||||||
del = false;
|
del = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AutoDelete::reset(const Path & p, bool recursive = true) {
|
||||||
|
this-> p = p;
|
||||||
|
this->recursive = recursive;
|
||||||
|
del = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -199,9 +199,11 @@ class AutoDelete
|
||||||
bool del;
|
bool del;
|
||||||
bool recursive;
|
bool recursive;
|
||||||
public:
|
public:
|
||||||
|
AutoDelete();
|
||||||
AutoDelete(const Path & p, bool recursive = true);
|
AutoDelete(const Path & p, bool recursive = true);
|
||||||
~AutoDelete();
|
~AutoDelete();
|
||||||
void cancel();
|
void cancel();
|
||||||
|
void reset(const Path & p, bool recursive = true);
|
||||||
operator Path() const { return path; }
|
operator Path() const { return path; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue