RemoteStore::addToStore(): Ensure capacity is decreased on exceptions

This commit is contained in:
Eelco Dolstra 2018-04-16 11:14:39 +02:00
parent a4c1618876
commit 3c2de9830d
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -7,6 +7,7 @@
#include "globals.hh"
#include "derivations.hh"
#include "pool.hh"
#include "finally.hh"
#include <sys/types.h>
#include <sys/stat.h>
@ -439,8 +440,10 @@ Path RemoteStore::addToStore(const string & name, const Path & _srcPath,
conn->to.written = 0;
conn->to.warn = true;
connections->incCapacity();
dumpPath(srcPath, conn->to, filter);
connections->decCapacity();
{
Finally cleanup([&]() { connections->decCapacity(); });
dumpPath(srcPath, conn->to, filter);
}
conn->to.warn = false;
conn->processStderr();
} catch (SysError & e) {