From 9ddd2a5d71b9604ecf4c460c0c85b665a34c2f2c Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Sun, 28 Mar 2021 23:06:48 +0200 Subject: [PATCH] Catch errors during filesystem rewrite --- src/mkdwarfs.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/mkdwarfs.cpp b/src/mkdwarfs.cpp index 6fdc0ff2..c5136e53 100644 --- a/src/mkdwarfs.cpp +++ b/src/mkdwarfs.cpp @@ -840,29 +840,30 @@ int mkdwarfs(int argc, char** argv) { auto ti = LOG_TIMED_INFO; - if (recompress) { - filesystem_v2::rewrite(lgr, prog, std::make_shared(path), fsw, - rw_opts); - wg_compress.wait(); - } else { - options.inode.with_similarity = - force_similarity || - options.file_order.mode == file_order_mode::SIMILARITY; - options.inode.with_nilsimsa = - options.file_order.mode == file_order_mode::NILSIMSA; + try { + if (recompress) { + filesystem_v2::rewrite(lgr, prog, std::make_shared(path), + fsw, rw_opts); + wg_compress.wait(); + } else { + options.inode.with_similarity = + force_similarity || + options.file_order.mode == file_order_mode::SIMILARITY; + options.inode.with_nilsimsa = + options.file_order.mode == file_order_mode::NILSIMSA; - scanner s(lgr, wg_scanner, cfg, entry_factory::create(), - std::make_shared(), std::move(script), options); + scanner s(lgr, wg_scanner, cfg, entry_factory::create(), + std::make_shared(), std::move(script), + options); - try { s.scan(fsw, path, prog); - } catch (runtime_error const& e) { - LOG_ERROR << e.what(); - return 1; - } catch (system_error const& e) { - LOG_ERROR << e.what(); - return 1; } + } catch (runtime_error const& e) { + LOG_ERROR << e.what(); + return 1; + } catch (system_error const& e) { + LOG_ERROR << e.what(); + return 1; } ofs.close();