forked from myfreeer/aria2-build-msys2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aria2-0001-options-change-default-path-to-current-dir.patch
75 lines (71 loc) · 2.85 KB
/
aria2-0001-options-change-default-path-to-current-dir.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From c33446e390e8d4fc79d69031d391eaf12dce1766 Mon Sep 17 00:00:00 2001
From: myfreeer <[email protected]>
Date: Tue, 5 Jun 2018 16:49:07 +0800
Subject: [PATCH 1/4] options: change default path to current dir
and try to load config files in current dir if exists
---
src/OptionHandlerFactory.cc | 2 +-
src/OptionHandlerImpl.cc | 2 +-
src/util.cc | 14 ++++++++++----
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc
index 3d76d33..cd00881 100644
--- a/src/OptionHandlerFactory.cc
+++ b/src/OptionHandlerFactory.cc
@@ -1276,7 +1276,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
}
{
OptionHandler* op(new LocalFilePathOptionHandler(
- PREF_NETRC_PATH, TEXT_NETRC_PATH, util::getHomeDir() + "/.netrc",
+ PREF_NETRC_PATH, TEXT_NETRC_PATH, File::getCurrentDir() + "/.netrc",
/* acceptStdin = */ false, 0, /* mustExist = */ false));
handlers.push_back(op);
}
diff --git a/src/OptionHandlerImpl.cc b/src/OptionHandlerImpl.cc
index 6214e84..7f89226 100644
--- a/src/OptionHandlerImpl.cc
+++ b/src/OptionHandlerImpl.cc
@@ -548,7 +548,7 @@ void LocalFilePathOptionHandler::parseArg(Option& option,
option.put(pref_, DEV_STDIN);
}
else {
- auto path = util::replace(optarg, "${HOME}", util::getHomeDir());
+ auto path = util::replace(optarg, "${HOME}", File::getCurrentDir());
if (mustExist_) {
File f(path);
std::string err;
diff --git a/src/util.cc b/src/util.cc
index 2e700de..cc2531d 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -1805,9 +1805,12 @@ std::string getXDGDir(const std::string& environmentVariable,
std::string getConfigFile()
{
- std::string filename = getHomeDir() + "/.aria2/aria2.conf";
+ std::string filename = File::getCurrentDir() + "/.aria2/aria2.conf";
if (!File(filename).exists()) {
- filename = getXDGDir("XDG_CONFIG_HOME", getHomeDir() + "/.config") +
+ filename = File::getCurrentDir() + "/aria2.conf";
+ }
+ if (!File(filename).exists()) {
+ filename = getXDGDir("XDG_CONFIG_HOME", File::getCurrentDir() + "/.config") +
"/aria2/aria2.conf";
}
return filename;
@@ -1816,9 +1819,12 @@ std::string getConfigFile()
std::string getDHTFile(bool ipv6)
{
std::string filename =
- getHomeDir() + (ipv6 ? "/.aria2/dht6.dat" : "/.aria2/dht.dat");
+ File::getCurrentDir() + (ipv6 ? "/.aria2/dht6.dat" : "/.aria2/dht.dat");
+ if (!File(filename).exists()) {
+ filename = File::getCurrentDir() + (ipv6 ? "/dht6.dat" : "/dht.dat");
+ }
if (!File(filename).exists()) {
- filename = getXDGDir("XDG_CACHE_HOME", getHomeDir() + "/.cache") +
+ filename = getXDGDir("XDG_CACHE_HOME", File::getCurrentDir() + "/.cache") +
(ipv6 ? "/aria2/dht6.dat" : "/aria2/dht.dat");
}
return filename;
--
2.17.1