From 3c2de9830dfa9e41927c666b7a7083c53886fb89 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 16 Apr 2018 11:14:39 +0200 Subject: RemoteStore::addToStore(): Ensure capacity is decreased on exceptions --- src/libstore/remote-store.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 76b5660355ed..ea86ef052f53 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 #include @@ -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) { -- cgit 1.4.1