From 49763c83f7075c64af2b06c07b46f8c256e21530 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sat, 26 Oct 2019 06:26:35 -0500 Subject: hscript: Remove temp dir from previous run, if any --- hscript/script.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'hscript') diff --git a/hscript/script.cc b/hscript/script.cc index 0e7e00d..f1f36b8 100644 --- a/hscript/script.cc +++ b/hscript/script.cc @@ -883,8 +883,12 @@ bool Script::execute() const { bool success; boost::system::error_code ec; - if(!fs::exists("/tmp/horizon", ec) && - !fs::create_directory("/tmp/horizon", ec)) { + /* assume create_directory will give us the error if removal fails */ + if(fs::exists("/tmp/horizon", ec)) { + fs::remove_all("/tmp/horizon", ec); + } + + if(!fs::create_directory("/tmp/horizon", ec)) { output_error("internal", "could not create temporary directory", ec.message()); return false; -- cgit v1.2.3-60-g2f50