From 203067a2742ad2cbb986369b216b1f1ecfb96458 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 29 Sep 2015 13:06:08 +0200 Subject: Automatically cleanup package archive, directory on failure --- bpkg/fetch.cxx | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'bpkg/fetch.cxx') diff --git a/bpkg/fetch.cxx b/bpkg/fetch.cxx index 3ddd2e9..ebff730 100644 --- a/bpkg/fetch.cxx +++ b/bpkg/fetch.cxx @@ -495,6 +495,8 @@ namespace bpkg fail << "file " << r << " already exists"; string url (to_url (host, port, f)); + + auto_rm arm (r); process pr (start (o, url, r)); if (!pr.wait ()) @@ -506,6 +508,7 @@ namespace bpkg info << "re-run with -v for more information"; } + arm.cancel (); return r; } @@ -576,6 +579,8 @@ namespace bpkg if (!ifs.is_open ()) fail << "unable to open " << f << " in read mode"; + auto_rm arm (r); + ofstream ofs (r.string (), ios::binary); if (!ofs.is_open ()) fail << "unable to open " << r << " in write mode"; @@ -589,6 +594,8 @@ namespace bpkg // ifs.close (); ofs.close (); + + arm.cancel (); } catch (const iostream::failure&) { -- cgit v1.1