diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-05-26 20:52:52 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-05-26 20:52:52 +0100 |
commit | 79b4a638bc33427cbfb4ca27646c241c9d477c1d (patch) | |
tree | c511c66124455631a8793329b2a09e44bb0f634f | |
parent | Updates to dependency scanner based on real world data (diff) | |
download | gentoobrowse-api-79b4a638bc33427cbfb4ca27646c241c9d477c1d.tar.bz2 gentoobrowse-api-79b4a638bc33427cbfb4ca27646c241c9d477c1d.tar.xz gentoobrowse-api-79b4a638bc33427cbfb4ca27646c241c9d477c1d.zip |
Always remove tmp dir after scan regardless of successfulness
-rw-r--r-- | gentoobrowse-api/service/maintenanceimpl.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gentoobrowse-api/service/maintenanceimpl.cpp b/gentoobrowse-api/service/maintenanceimpl.cpp index 4ac065c..d5c6b64 100644 --- a/gentoobrowse-api/service/maintenanceimpl.cpp +++ b/gentoobrowse-api/service/maintenanceimpl.cpp @@ -3,6 +3,7 @@ #include <tablepatch.h> #include <sqlWriter.h> #include <buffer.h> +#include <scopeExit.h> #include <boost/filesystem/operations.hpp> #include <sql/maintenance/createTempFileListTable.sql.h> #include <sql/maintenance/fileList.sql.h> @@ -172,7 +173,6 @@ namespace Gentoo { for (const auto & fp : fps) { fp.second->apply(dbc); } - boost::filesystem::remove_all(tmp); dbc->execute("DROP TABLE filelist"); for (const auto & fp : fps) { fp.second->tidy(dbc); @@ -183,6 +183,10 @@ namespace Gentoo { Maintenance::refreshPackageTree(const Ice::Current &) { auto tmp = boost::filesystem::temp_directory_path() / "import"; + AdHoc::ScopeExit([&tmp]{ + boost::system::error_code ec; + boost::filesystem::remove_all(tmp, ec); + }); auto dbc = db->get(); dbc->execute("SET search_path = gentoobrowse, pg_catalog"); DB::TransactionScope tx(dbc.get()); |