mirror of
https://github.com/ModOrganizer2/mob.git
synced 2026-07-27 14:07:05 -07:00
fixed empty tool name
delete temp extractor directory if it exists
This commit is contained in:
@@ -114,7 +114,8 @@ fs::path downloader::path_for_url(const mob::url& u) const
|
||||
const std::string strip = "/download";
|
||||
|
||||
cx_->trace(context::net,
|
||||
"url " + u.string() + " is sourceforge, stripping " + strip);
|
||||
"url " + u.string() + " is sourceforge, "
|
||||
"stripping " + strip + " for filename");
|
||||
|
||||
if (url_string.ends_with(strip))
|
||||
url_string = url_string.substr(0, url_string.size() - strip.size());
|
||||
|
||||
+14
-7
@@ -163,21 +163,28 @@ void extractor::check_duplicate_directory(const fs::path& ifile)
|
||||
|
||||
// give it a temp name in case there's yet another directory with the
|
||||
// same name in it
|
||||
const auto temp_dir_name = where_ / ("_mob_" + dir_name );
|
||||
const auto temp_dir = where_ / ("_mob_" + dir_name );
|
||||
|
||||
cx_->trace(context::generic,
|
||||
"renaming dir to " + temp_dir_name.string() + " to avoid clashes");
|
||||
"renaming dir to " + temp_dir.string() + " to avoid clashes");
|
||||
|
||||
op::rename(*cx_,
|
||||
where_ / dir_name,
|
||||
where_ / temp_dir_name);
|
||||
if (fs::exists(temp_dir))
|
||||
{
|
||||
cx_->trace(context::generic,
|
||||
"temp dir " + temp_dir.string() + " already exists, "
|
||||
"deleting");
|
||||
|
||||
op::delete_directory(*cx_, temp_dir);
|
||||
}
|
||||
|
||||
op::rename(*cx_, where_ / dir_name, temp_dir);
|
||||
|
||||
// move the content of the directory up
|
||||
for (auto e : fs::directory_iterator(where_ / temp_dir_name))
|
||||
for (auto e : fs::directory_iterator(temp_dir))
|
||||
op::move_to_directory(*cx_, e.path(), where_);
|
||||
|
||||
// delete the old directory, which should be empty now
|
||||
op::delete_directory(*cx_, where_ / temp_dir_name);
|
||||
op::delete_directory(*cx_, temp_dir);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -10,7 +10,7 @@ basic_process_runner::basic_process_runner(std::string name)
|
||||
{
|
||||
}
|
||||
|
||||
std::string basic_process_runner::name() const
|
||||
std::string basic_process_runner::do_name() const
|
||||
{
|
||||
return process_.name();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@ tool& tool::operator=(tool&& t)
|
||||
|
||||
std::string tool::name() const
|
||||
{
|
||||
std::string s = do_name();
|
||||
if (!s.empty())
|
||||
return s;
|
||||
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -17,7 +17,7 @@ public:
|
||||
|
||||
virtual ~tool() = default;
|
||||
|
||||
virtual std::string name() const;
|
||||
std::string name() const;
|
||||
|
||||
void run(context& cx);
|
||||
void interrupt();
|
||||
@@ -30,8 +30,10 @@ protected:
|
||||
tool(std::string name);
|
||||
|
||||
bool interrupted() const;
|
||||
|
||||
virtual void do_run() = 0;
|
||||
virtual void do_interrupt() = 0;
|
||||
virtual std::string do_name() const { return {}; }
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
@@ -66,7 +68,7 @@ private:
|
||||
class basic_process_runner : public tool
|
||||
{
|
||||
public:
|
||||
std::string name() const override;
|
||||
std::string do_name() const override;
|
||||
void join();
|
||||
int exit_code() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user