mirror of
https://github.com/ModOrganizer2/mob.git
synced 2026-07-27 14:07:05 -07:00
added git options in ini
moved all the code from git_command to the git tool changed task_conf_holder to make the git tool since it's getting pretty complex fixed task name in options not supporting super fixed pipes behaving weirdly when copying process objects
This commit is contained in:
@@ -8,9 +8,19 @@ file_log_level = 5
|
||||
log_file = mob.log
|
||||
|
||||
[options]
|
||||
mo_org = ModOrganizer2
|
||||
mo_branch = master
|
||||
no_pull = false
|
||||
mo_org = ModOrganizer2
|
||||
mo_branch = master
|
||||
no_pull = false
|
||||
ignore_ts = false
|
||||
|
||||
git_username =
|
||||
git_email =
|
||||
|
||||
set_origin_remote = false
|
||||
remote_username =
|
||||
remote_key =
|
||||
remote_no_push_upstream = false
|
||||
remote_push_default_origin = false
|
||||
|
||||
[tools]
|
||||
sevenz = 7z.exe
|
||||
|
||||
+8
-212
@@ -758,9 +758,9 @@ clipp::group git_command::do_group()
|
||||
& clipp::value("NAME") >> remote_)
|
||||
% "name of new remote",
|
||||
|
||||
(clipp::required("-u", "--url")
|
||||
& clipp::value("URL") >> url_)
|
||||
% "remote URL",
|
||||
(clipp::required("-u", "--username")
|
||||
& clipp::value("USERNAME") >> username_)
|
||||
% "git username",
|
||||
|
||||
(clipp::option("-k", "--key")
|
||||
& clipp::value("PATH") >> key_)
|
||||
@@ -840,27 +840,8 @@ void git_command::do_set_remotes()
|
||||
for (auto&& r : repos)
|
||||
{
|
||||
u8cout << "setting up " << path_to_utf8(r.filename()) << "\n";
|
||||
|
||||
set_config(r, "user.name", username_);
|
||||
set_config(r, "user.email", email_);
|
||||
|
||||
if (!has_remote(r, "upstream"))
|
||||
{
|
||||
const auto gf = git_file(r);
|
||||
|
||||
rename_remote(r, "origin", "upstream");
|
||||
|
||||
if (nopush_)
|
||||
set_remote_push_url(r, "upstream", "nopushurl");
|
||||
|
||||
add_remote(r, "origin", make_url(gf));
|
||||
|
||||
if (push_default_)
|
||||
set_config(r, "remote.pushdefault", "origin");
|
||||
|
||||
if (!key_.empty())
|
||||
set_config(r, "remote.origin.puttykeyfile", key_);
|
||||
}
|
||||
git::set_credentials(r, username_, email_);
|
||||
git::set_remote(r, username_, key_, nopush_, push_default_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -870,22 +851,12 @@ void git_command::do_add_remote()
|
||||
|
||||
u8cout
|
||||
<< "adding remote '" << remote_ << "' "
|
||||
<< "from '" << url_ << "' to repos\n";
|
||||
<< "from '" << username_ << "' to repos\n";
|
||||
|
||||
for (auto&& r : repos)
|
||||
{
|
||||
u8cout << path_to_utf8(r.filename()) << "\n";
|
||||
|
||||
if (!has_remote(r, remote_))
|
||||
{
|
||||
add_remote(r, remote_, url_);
|
||||
|
||||
if (push_default_)
|
||||
set_config(r, "remote.pushdefault", remote_);
|
||||
|
||||
if (!key_.empty())
|
||||
set_config(r, "remote." + remote_ + ".puttykeyfile", key_);
|
||||
}
|
||||
git::add_remote(r, remote_, username_, key_, push_default_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -901,31 +872,7 @@ void git_command::do_ignore_ts()
|
||||
for (auto&& r : repos)
|
||||
{
|
||||
u8cout << path_to_utf8(r.filename()) << "\n";
|
||||
|
||||
for (auto&& e : fs::recursive_directory_iterator(r))
|
||||
{
|
||||
if (!e.is_regular_file())
|
||||
continue;
|
||||
|
||||
const auto p = e.path();
|
||||
|
||||
if (!path_to_utf8(p.extension()).ends_with(".ts"))
|
||||
continue;
|
||||
|
||||
const auto rp = fs::relative(p, r);
|
||||
|
||||
if (is_tracked(r, rp))
|
||||
{
|
||||
u8cout << " . " << path_to_utf8(rp) << "\n";
|
||||
set_assume_unchanged(r, rp, tson_);
|
||||
}
|
||||
else
|
||||
{
|
||||
u8cout
|
||||
<< " . "
|
||||
<< path_to_utf8(rp) << " (skipping, not tracked)\n";
|
||||
}
|
||||
}
|
||||
git::ignore_ts(r, tson_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -960,157 +907,6 @@ std::vector<fs::path> git_command::get_repos() const
|
||||
return v;
|
||||
}
|
||||
|
||||
void git_command::set_config(
|
||||
const fs::path& repo, const std::string& key, const std::string& value)
|
||||
{
|
||||
auto p = process()
|
||||
.binary(git::binary())
|
||||
.arg("config")
|
||||
.arg(key)
|
||||
.arg(value)
|
||||
.cwd(repo);
|
||||
|
||||
p.run();
|
||||
p.join();
|
||||
}
|
||||
|
||||
bool git_command::has_remote(const fs::path& repo, const std::string& name)
|
||||
{
|
||||
auto p = process()
|
||||
.binary(git::binary())
|
||||
.flags(process::allow_failure)
|
||||
.stderr_level(context::level::debug)
|
||||
.arg("remote")
|
||||
.arg("show")
|
||||
.arg(name)
|
||||
.cwd(repo);
|
||||
|
||||
p.run();
|
||||
p.join();
|
||||
|
||||
return (p.exit_code() == 0);
|
||||
}
|
||||
|
||||
void git_command::rename_remote(
|
||||
const fs::path& repo,
|
||||
const std::string& from, const std::string& to)
|
||||
{
|
||||
auto p = process()
|
||||
.binary(git::binary())
|
||||
.arg("remote")
|
||||
.arg("rename")
|
||||
.arg(from)
|
||||
.arg(to)
|
||||
.cwd(repo);
|
||||
|
||||
p.run();
|
||||
p.join();
|
||||
}
|
||||
|
||||
void git_command::add_remote(
|
||||
const fs::path& repo,
|
||||
const std::string& name, const std::string& url)
|
||||
{
|
||||
auto p = process()
|
||||
.binary(git::binary())
|
||||
.arg("remote")
|
||||
.arg("add")
|
||||
.arg(name)
|
||||
.arg(url)
|
||||
.cwd(repo);
|
||||
|
||||
p.run();
|
||||
p.join();
|
||||
}
|
||||
|
||||
void git_command::set_remote_push_url(
|
||||
const fs::path& repo,
|
||||
const std::string& remote, const std::string& url)
|
||||
{
|
||||
auto p = process()
|
||||
.binary(git::binary())
|
||||
.arg("remote")
|
||||
.arg("set-url")
|
||||
.arg("--push")
|
||||
.arg(remote)
|
||||
.arg(url)
|
||||
.cwd(repo);
|
||||
|
||||
p.run();
|
||||
p.join();
|
||||
}
|
||||
|
||||
void git_command::set_assume_unchanged(
|
||||
const fs::path& repo, const fs::path& relative_file, bool on)
|
||||
{
|
||||
auto p = process()
|
||||
.binary(git::binary())
|
||||
.arg("update-index")
|
||||
.arg(on ? "--assume-unchanged" : "--no-assume-unchanged")
|
||||
.arg(relative_file, process::forward_slashes)
|
||||
.cwd(repo);
|
||||
|
||||
p.run();
|
||||
p.join();
|
||||
}
|
||||
|
||||
bool git_command::is_tracked(
|
||||
const fs::path& repo, const fs::path& relative_file)
|
||||
{
|
||||
auto p = process()
|
||||
.binary(git::binary())
|
||||
.stdout_level(context::level::debug)
|
||||
.stderr_level(context::level::debug)
|
||||
.flags(process::allow_failure)
|
||||
.arg("ls-files")
|
||||
.arg("--error-unmatch")
|
||||
.arg(relative_file, process::forward_slashes)
|
||||
.cwd(repo);
|
||||
|
||||
p.run();
|
||||
p.join();
|
||||
|
||||
return (p.exit_code() == 0);
|
||||
}
|
||||
|
||||
std::string git_command::git_file(const fs::path& repo)
|
||||
{
|
||||
auto p = process()
|
||||
.binary(git::binary())
|
||||
.stdout_flags(process::keep_in_string)
|
||||
.arg("remote")
|
||||
.arg("get-url")
|
||||
.arg("origin")
|
||||
.cwd(repo);
|
||||
|
||||
p.run();
|
||||
p.join();
|
||||
|
||||
const std::string out = p.stdout_string();
|
||||
|
||||
const auto last_slash = out.find_last_of("/");
|
||||
if (last_slash == std::string::npos)
|
||||
{
|
||||
u8cerr << "bad get-url output '" << out << "'\n";
|
||||
throw bailed();
|
||||
}
|
||||
|
||||
auto s = trim_copy(out.substr(last_slash + 1));
|
||||
|
||||
if (s.empty())
|
||||
{
|
||||
u8cerr << "bad get-url output '" << out << "'\n";
|
||||
throw bailed();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string git_command::make_url(const std::string& git_file)
|
||||
{
|
||||
return "git@github.com:" + username_ + "/" + git_file;
|
||||
}
|
||||
|
||||
|
||||
cmake_command::cmake_command()
|
||||
: command(requires_options)
|
||||
|
||||
@@ -185,7 +185,6 @@ private:
|
||||
std::string email_;
|
||||
std::string key_;
|
||||
std::string remote_;
|
||||
std::string url_;
|
||||
bool tson_ = false;
|
||||
bool nopush_ = false;
|
||||
bool push_default_ = false;
|
||||
@@ -195,34 +194,6 @@ private:
|
||||
void do_ignore_ts();
|
||||
|
||||
std::vector<fs::path> get_repos() const;
|
||||
|
||||
void set_config(
|
||||
const fs::path& repo,
|
||||
const std::string& key, const std::string& value);
|
||||
|
||||
bool has_remote(
|
||||
const fs::path& repo,
|
||||
const std::string& name);
|
||||
|
||||
void rename_remote(
|
||||
const fs::path& repo,
|
||||
const std::string& from, const std::string& to);
|
||||
|
||||
void add_remote(
|
||||
const fs::path& repo,
|
||||
const std::string& name, const std::string& url);
|
||||
|
||||
void set_remote_push_url(
|
||||
const fs::path& repo,
|
||||
const std::string& remote, const std::string& url);
|
||||
|
||||
void set_assume_unchanged(
|
||||
const fs::path& repo, const fs::path& relative_file, bool on);
|
||||
|
||||
bool is_tracked(const fs::path& repo, const fs::path& relative_file);
|
||||
|
||||
std::string git_file(const fs::path& repo);
|
||||
std::string make_url(const std::string& git_file);
|
||||
};
|
||||
|
||||
|
||||
|
||||
+28
-1
@@ -3,6 +3,7 @@
|
||||
#include "utility.h"
|
||||
#include "context.h"
|
||||
#include "process.h"
|
||||
#include "tasks/task.h"
|
||||
#include "tools/tools.h"
|
||||
|
||||
namespace mob
|
||||
@@ -84,6 +85,18 @@ std::string conf::get_for_task(
|
||||
break;
|
||||
}
|
||||
|
||||
if (task == map_.end())
|
||||
{
|
||||
for (auto&& tn : task_names)
|
||||
{
|
||||
if (is_super_task(tn))
|
||||
{
|
||||
task = map_.find("super");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (task == map_.end())
|
||||
return get_global(section, key);
|
||||
|
||||
@@ -102,7 +115,7 @@ void conf::set_for_task(
|
||||
const std::string& task_name, const std::string& section,
|
||||
const std::string& key, const std::string& value)
|
||||
{
|
||||
// make sure it exists, will throw if it doesn't
|
||||
// make sure the key exists, will throw if it doesn't
|
||||
get_global(section, key);
|
||||
|
||||
map_[task_name][section][key] = value;
|
||||
@@ -651,6 +664,9 @@ void parse_section(
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!task_exists(task))
|
||||
ini_error(ini, i, "task '" + task + "' doesn't exist");
|
||||
|
||||
conf::set_for_task(task, section, k, v);
|
||||
}
|
||||
|
||||
@@ -846,9 +862,20 @@ void init_options(
|
||||
const auto po = parse_option(o);
|
||||
|
||||
if (po.task.empty())
|
||||
{
|
||||
conf::set_global(po.section, po.key, po.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!task_exists(po.task))
|
||||
{
|
||||
gcx().bail_out(context::generic,
|
||||
"task '{}' doesn't exist (command line option)",
|
||||
po.task);
|
||||
}
|
||||
|
||||
conf::set_for_task(po.task, po.section, po.key, po.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +226,12 @@ process::impl::impl(const impl& i)
|
||||
|
||||
process::impl& process::impl::operator=(const impl& i)
|
||||
{
|
||||
handle = {};
|
||||
job = {};
|
||||
interrupt = i.interrupt.load();
|
||||
stdout_pipe = {};
|
||||
stderr_pipe = {};
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public:
|
||||
|
||||
static process raw(const context& cx, const std::string& cmd);
|
||||
|
||||
static process pipe(const process& p)
|
||||
static process pipe(process p)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ fs::path boost_di::source_path()
|
||||
|
||||
void boost_di::do_fetch()
|
||||
{
|
||||
run_tool(git(task_conf().git_op())
|
||||
run_tool(task_conf().make_git()
|
||||
.url(make_github_url("boost-experimental", "di"))
|
||||
.branch("cpp14")
|
||||
.output(source_path()));
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ void gtest::do_clean_for_rebuild()
|
||||
|
||||
void gtest::do_fetch()
|
||||
{
|
||||
run_tool(git(task_conf().git_op())
|
||||
run_tool(task_conf().make_git()
|
||||
.url(make_github_url("google", "googletest"))
|
||||
.branch(version())
|
||||
.output(source_path()));
|
||||
|
||||
@@ -26,7 +26,7 @@ fs::path libffi::source_path()
|
||||
|
||||
void libffi::do_fetch()
|
||||
{
|
||||
run_tool(git(task_conf().git_op())
|
||||
run_tool(task_conf().make_git()
|
||||
.url(make_github_url("python","cpython-bin-deps"))
|
||||
.branch("libffi")
|
||||
.output(source_path()));
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ void lz4::build_and_install_prebuilt()
|
||||
|
||||
void lz4::fetch_from_source()
|
||||
{
|
||||
run_tool(git(task_conf().git_op())
|
||||
run_tool(task_conf().make_git()
|
||||
.url(make_github_url("lz4","lz4"))
|
||||
.branch(version())
|
||||
.output(source_path()));
|
||||
|
||||
@@ -58,7 +58,7 @@ void modorganizer::do_fetch()
|
||||
{
|
||||
initialize_super(super_path());
|
||||
|
||||
run_tool(git(task_conf().git_op())
|
||||
run_tool(task_conf().make_git()
|
||||
.url(make_github_url(task_conf().mo_org(), repo_))
|
||||
.branch(task_conf().mo_branch())
|
||||
.output(this_source_path()));
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ void ncc::do_clean_for_rebuild()
|
||||
|
||||
void ncc::do_fetch()
|
||||
{
|
||||
run_tool(git(task_conf().git_op())
|
||||
run_tool(task_conf().make_git()
|
||||
.url(make_github_url(task_conf().mo_org(), "modorganizer-NCC"))
|
||||
.branch(task_conf().mo_branch())
|
||||
.output(source_path()));
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ void nmm::do_clean_for_rebuild()
|
||||
|
||||
void nmm::do_fetch()
|
||||
{
|
||||
run_tool(git(task_conf().git_op())
|
||||
run_tool(task_conf().make_git()
|
||||
.url(make_github_url("Nexus-Mods", "Nexus-Mod-Manager"))
|
||||
.branch(version())
|
||||
.output(source_path()));
|
||||
|
||||
@@ -111,7 +111,7 @@ void python::build_and_install_prebuilt()
|
||||
|
||||
void python::fetch_from_source()
|
||||
{
|
||||
run_tool(git(task_conf().git_op())
|
||||
run_tool(task_conf().make_git()
|
||||
.url(make_github_url("python", "cpython"))
|
||||
.branch(version())
|
||||
.output(source_path()));
|
||||
|
||||
@@ -26,7 +26,7 @@ fs::path spdlog::source_path()
|
||||
|
||||
void spdlog::do_fetch()
|
||||
{
|
||||
run_tool(git(task_conf().git_op())
|
||||
run_tool(task_conf().make_git()
|
||||
.url(make_github_url("gabime", "spdlog"))
|
||||
.branch(version())
|
||||
.output(source_path()));
|
||||
|
||||
+78
-1
@@ -151,6 +151,37 @@ void run_all_tasks()
|
||||
run_tasks(tasks);
|
||||
}
|
||||
|
||||
bool task_exists(const std::string& name)
|
||||
{
|
||||
if (name == "super")
|
||||
return true;
|
||||
|
||||
for (auto&& t : g_all_tasks)
|
||||
{
|
||||
for (auto&& n : t->names())
|
||||
{
|
||||
if (n == name)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_super_task(const std::string& name)
|
||||
{
|
||||
for (auto& t : g_all_tasks)
|
||||
{
|
||||
for (auto&& tn : t->names())
|
||||
{
|
||||
if (tn == name)
|
||||
return t->is_super();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
struct task::thread_context
|
||||
{
|
||||
@@ -164,6 +195,52 @@ struct task::thread_context
|
||||
};
|
||||
|
||||
|
||||
task_conf_holder::task_conf_holder(const task& t)
|
||||
: task_(t)
|
||||
{
|
||||
}
|
||||
|
||||
std::string task_conf_holder::mo_org()
|
||||
{
|
||||
return conf::option_by_name(task_.names(), "mo_org");
|
||||
}
|
||||
|
||||
std::string task_conf_holder::mo_branch()
|
||||
{
|
||||
return conf::option_by_name(task_.names(), "mo_branch");
|
||||
}
|
||||
|
||||
bool task_conf_holder::no_pull()
|
||||
{
|
||||
return conf::bool_option_by_name(task_.names(), "no_pull");
|
||||
}
|
||||
|
||||
git task_conf_holder::make_git()
|
||||
{
|
||||
git g(no_pull() ? git::clone : git::clone_or_pull);
|
||||
|
||||
g.ignore_ts(conf::bool_option_by_name(task_.names(), "ignore_ts"));
|
||||
|
||||
g.credentials(
|
||||
conf::option_by_name(task_.names(), "git_username"),
|
||||
conf::option_by_name(task_.names(), "git_email")
|
||||
);
|
||||
|
||||
if (conf::bool_option_by_name(task_.names(), "set_origin_remote"))
|
||||
{
|
||||
g.remote(
|
||||
conf::option_by_name(task_.names(), "remote_username"),
|
||||
conf::option_by_name(task_.names(), "remote_key"),
|
||||
conf::bool_option_by_name(task_.names(), "remote_no_push_upstream"),
|
||||
conf::bool_option_by_name(task_.names(), "remote_push_default_origin")
|
||||
);
|
||||
}
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
|
||||
task::task(std::vector<std::string> names)
|
||||
: names_(std::move(names)), interrupted_(false)
|
||||
{
|
||||
@@ -290,7 +367,7 @@ void task::parallel(std::vector<std::pair<std::string, std::function<void ()>>>
|
||||
|
||||
task_conf_holder task::task_conf() const
|
||||
{
|
||||
return task_conf_holder(names_);
|
||||
return task_conf_holder(*this);
|
||||
}
|
||||
|
||||
void task::run()
|
||||
|
||||
+8
-26
@@ -25,41 +25,23 @@ void run_task(const std::string& name);
|
||||
void run_tasks(const std::vector<std::string>& names);;
|
||||
void run_all_tasks();
|
||||
void list_tasks(bool err=false);
|
||||
bool task_exists(const std::string& name);
|
||||
bool is_super_task(const std::string& name);
|
||||
|
||||
|
||||
class task_conf_holder
|
||||
{
|
||||
public:
|
||||
task_conf_holder(std::vector<std::string> names)
|
||||
: names_(std::move(names))
|
||||
{
|
||||
}
|
||||
task_conf_holder(const task& t);
|
||||
|
||||
std::string mo_org()
|
||||
{
|
||||
return conf::option_by_name(names_, "mo_org");
|
||||
}
|
||||
std::string mo_org();
|
||||
std::string mo_branch();
|
||||
bool no_pull();
|
||||
|
||||
std::string mo_branch()
|
||||
{
|
||||
return conf::option_by_name(names_, "mo_branch");
|
||||
}
|
||||
|
||||
bool no_pull()
|
||||
{
|
||||
return conf::bool_option_by_name(names_, "no_pull");
|
||||
}
|
||||
|
||||
git::ops git_op()
|
||||
{
|
||||
if (no_pull())
|
||||
return git::clone;
|
||||
else
|
||||
return git::clone_or_pull2;
|
||||
}
|
||||
git make_git();
|
||||
|
||||
private:
|
||||
std::vector<std::string> names_;
|
||||
const task& task_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ void usvfs::build_and_install_prebuilt()
|
||||
|
||||
void usvfs::fetch_from_source()
|
||||
{
|
||||
run_tool(git(task_conf().git_op())
|
||||
run_tool(task_conf().make_git()
|
||||
.url(make_github_url(task_conf().mo_org(), "usvfs"))
|
||||
.branch(version())
|
||||
.output(source_path()));
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ fs::path cmake::result() const
|
||||
void cmake::do_run()
|
||||
{
|
||||
if (root_.empty())
|
||||
cx_->bail_out(context::generic, "cmake output path is empty");
|
||||
cx().bail_out(context::generic, "cmake output path is empty");
|
||||
|
||||
const auto& g = get_generator(gen_);
|
||||
|
||||
|
||||
+16
-16
@@ -34,9 +34,9 @@ fs::path downloader::result() const
|
||||
|
||||
void downloader::do_run()
|
||||
{
|
||||
dl_.reset(new curl_downloader(cx_));
|
||||
dl_.reset(new curl_downloader(&cx()));
|
||||
|
||||
cx_->trace(context::net, "looking for already downloaded files");
|
||||
cx().trace(context::net, "looking for already downloaded files");
|
||||
|
||||
if (!file_.empty())
|
||||
{
|
||||
@@ -58,9 +58,9 @@ void downloader::do_run()
|
||||
}
|
||||
|
||||
|
||||
cx_->trace(context::net, "no cached downloads were found, will try:");
|
||||
cx().trace(context::net, "no cached downloads were found, will try:");
|
||||
for (auto&& u : urls_)
|
||||
cx_->trace(context::net, " . {}", u);
|
||||
cx().trace(context::net, " . {}", u);
|
||||
|
||||
|
||||
// try them in order
|
||||
@@ -69,29 +69,29 @@ void downloader::do_run()
|
||||
if (file_.empty())
|
||||
file_ = path_for_url(u);
|
||||
|
||||
cx_->trace(context::net, "trying {} into {}", u, file_);
|
||||
cx().trace(context::net, "trying {} into {}", u, file_);
|
||||
|
||||
dl_->start(u, file_);
|
||||
cx_->trace(context::net, "waiting for download");
|
||||
cx().trace(context::net, "waiting for download");
|
||||
dl_->join();
|
||||
|
||||
if (dl_->ok())
|
||||
{
|
||||
cx_->trace(context::net, "file {} downloaded", file_);
|
||||
cx().trace(context::net, "file {} downloaded", file_);
|
||||
return;
|
||||
}
|
||||
|
||||
cx_->debug(context::net, "download failed");
|
||||
cx().debug(context::net, "download failed");
|
||||
}
|
||||
|
||||
if (interrupted())
|
||||
{
|
||||
cx_->trace(context::interruption, "");
|
||||
cx().trace(context::interruption, "");
|
||||
return;
|
||||
}
|
||||
|
||||
// all failed
|
||||
cx_->bail_out(context::net, "all urls failed to download");
|
||||
cx().bail_out(context::net, "all urls failed to download");
|
||||
}
|
||||
|
||||
void downloader::do_interrupt()
|
||||
@@ -106,18 +106,18 @@ bool downloader::try_picking(const fs::path& file)
|
||||
{
|
||||
if (conf::redownload())
|
||||
{
|
||||
cx_->trace(context::redownload, "deleting {}", file);
|
||||
op::delete_file(*cx_, file, op::optional);
|
||||
cx().trace(context::redownload, "deleting {}", file);
|
||||
op::delete_file(cx(), file, op::optional);
|
||||
}
|
||||
else
|
||||
{
|
||||
cx_->trace(context::bypass, "picking {}", file_);
|
||||
cx().trace(context::bypass, "picking {}", file_);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cx_->trace(context::net, "no {}", file);
|
||||
cx().trace(context::net, "no {}", file);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -134,13 +134,13 @@ fs::path downloader::path_for_url(const mob::url& u) const
|
||||
// sf downloads end with /download, strip it to get the filename
|
||||
const std::string strip = "/download";
|
||||
|
||||
cx_->trace(context::net,
|
||||
cx().trace(context::net,
|
||||
"url {} is sourceforge, stripping {} for filename", u, strip);
|
||||
|
||||
if (url_string.ends_with(strip))
|
||||
url_string = url_string.substr(0, url_string.size() - strip.size());
|
||||
else
|
||||
cx_->trace(context::net, "no need to strip {}", u);
|
||||
cx().trace(context::net, "no need to strip {}", u);
|
||||
|
||||
filename = mob::url(url_string).filename();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user