diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-09-29 13:06:08 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-09-29 13:06:08 +0200 |
commit | 203067a2742ad2cbb986369b216b1f1ecfb96458 (patch) | |
tree | b3b755ca08aba82a8b780b462dce877afe9d0bea /bpkg/fetch.cxx | |
parent | f5adc6c0ee7965abcad4cc73d0f36d1ed3cba3cc (diff) |
Automatically cleanup package archive, directory on failure
Diffstat (limited to 'bpkg/fetch.cxx')
-rw-r--r-- | bpkg/fetch.cxx | 7 |
1 files changed, 7 insertions, 0 deletions
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&) { |