This commit is contained in:
30
src/main.cpp
30
src/main.cpp
@@ -14,14 +14,30 @@ std::atomic<bool> g_running{true};
|
||||
std::unique_ptr<Server> g_server;
|
||||
std::thread g_server_thread;
|
||||
|
||||
std::filesystem::path get_config_path() {
|
||||
std::filesystem::path system_config_path = "/data/sos_config.json";
|
||||
std::filesystem::path user_config_path = std::filesystem::path(std::getenv("HOME")) / ".config/simple_object_storage/config.json";
|
||||
std::filesystem::path get_executable_path() {
|
||||
return std::filesystem::read_symlink("/proc/self/exe");
|
||||
}
|
||||
|
||||
if (std::filesystem::exists(system_config_path)) return system_config_path;
|
||||
if (std::filesystem::exists(user_config_path)) return user_config_path;
|
||||
|
||||
std::cout << "No config file found. Checked " << system_config_path << " and " << user_config_path << std::endl;
|
||||
std::filesystem::path get_config_path() {
|
||||
const std::filesystem::path _home = std::getenv("HOME");
|
||||
const std::filesystem::path _exe = get_executable_path().parent_path();
|
||||
|
||||
// check for config in the following paths:
|
||||
std::vector<std::filesystem::path> config_paths = {
|
||||
"/data/sos_config.json",
|
||||
_home / ".config/simple_object_storage/config.json",
|
||||
_exe / ".." / ".test-docker" / "config.json"
|
||||
};
|
||||
|
||||
for (const auto& path : config_paths) {
|
||||
if (std::filesystem::exists(path)) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
std::cout << "No config file found. Checked: " << std::endl;
|
||||
for (const auto& path : config_paths) {
|
||||
std::cout << " " << path << std::endl;
|
||||
}
|
||||
return std::filesystem::path();
|
||||
}
|
||||
|
||||
|
1
test.sh.downloaded1
Normal file
1
test.sh.downloaded1
Normal file
@@ -0,0 +1 @@
|
||||
{"error":"Couldn't find: null","result":"error"}
|
1
test.sh.downloaded2
Normal file
1
test.sh.downloaded2
Normal file
@@ -0,0 +1 @@
|
||||
{"error":"Couldn't find: autotest:test1","result":"error"}
|
Reference in New Issue
Block a user