From 780290277a51853b2e515b16898ca0fcfa1e9e71 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 26 Feb 2018 22:00:22 +0300 Subject: Update rep-fetch --- bpkg/utility.cxx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'bpkg/utility.cxx') diff --git a/bpkg/utility.cxx b/bpkg/utility.cxx index 252bdef..d80e55e 100644 --- a/bpkg/utility.cxx +++ b/bpkg/utility.cxx @@ -69,7 +69,11 @@ namespace bpkg { if (!temp_dir.empty ()) { - rm_r (temp_dir, true /* dir_itself */, 3, ignore_error); + rm_r (temp_dir, + true /* dir_itself */, + 3, + ignore_error ? rm_error_mode::ignore : rm_error_mode::fail); + temp_dir.clear (); } } @@ -202,19 +206,24 @@ namespace bpkg } void - rm_r (const dir_path& d, bool dir, uint16_t v, bool ignore_error) + rm_r (const dir_path& d, bool dir, uint16_t v, rm_error_mode m) { if (verb >= v) text << (dir ? "rmdir -r " : "rm -r ") << (dir ? d : d / dir_path ("*")); try { - rmdir_r (d, dir, ignore_error); + rmdir_r (d, dir, m == rm_error_mode::ignore); } catch (const system_error& e) { - fail << "unable to remove " << (dir ? "" : "contents of ") - << "directory " << d << ": " << e; + bool w (m == rm_error_mode::warn); + + (w ? warn : error) << "unable to remove " << (dir ? "" : "contents of ") + << "directory " << d << ": " << e; + + if (!w) + throw failed (); } } -- cgit v1.1