diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-26 06:26:35 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-26 06:26:35 -0500 |
commit | 49763c83f7075c64af2b06c07b46f8c256e21530 (patch) | |
tree | 1d452f627e4dcb9150e15b4767ac91aa956197d3 /hscript/script.cc | |
parent | 88c8c43edb283788c3bdc6d4cb2c07ac1eea9f88 (diff) | |
download | horizon-49763c83f7075c64af2b06c07b46f8c256e21530.tar.gz horizon-49763c83f7075c64af2b06c07b46f8c256e21530.tar.bz2 horizon-49763c83f7075c64af2b06c07b46f8c256e21530.tar.xz horizon-49763c83f7075c64af2b06c07b46f8c256e21530.zip |
hscript: Remove temp dir from previous run, if any
Diffstat (limited to 'hscript/script.cc')
-rw-r--r-- | hscript/script.cc | 8 |
1 files changed, 6 insertions, 2 deletions
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; |