diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-04-16 11:14:39 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2018-05-30 13:48:31 +0200 |
commit | 3c2de9830dfa9e41927c666b7a7083c53886fb89 (patch) | |
tree | 766bce69e8c0e60ae2970c5639ace94bd4cd7702 | |
parent | a4c16188760fde2122df534f5db6b9ef26c9bc22 (diff) |
RemoteStore::addToStore(): Ensure capacity is decreased on exceptions
-rw-r--r-- | src/libstore/remote-store.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 76b566035..ea86ef052 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -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) { |