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