Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

[develop] <wallet_plugin> Preemptively create the wallet directory to prevent exception #8490

Merged
merged 3 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions plugins/wallet_plugin/wallet_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ void wallet_plugin::plugin_initialize(const variables_map& options) {
if (options.count("wallet-dir")) {
auto dir = options.at("wallet-dir").as<boost::filesystem::path>();
if (dir.is_relative())
wallet_manager_ptr->set_dir(app().data_dir() / dir);
else
wallet_manager_ptr->set_dir(dir);
dir = app().data_dir() / dir;
if( !bfs::exists(dir) )
bfs::create_directories(dir);
wallet_manager_ptr->set_dir(dir);
}
if (options.count("unlock-timeout")) {
auto timeout = options.at("unlock-timeout").as<int64_t>();
Expand Down
10 changes: 8 additions & 2 deletions programs/keosd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ bfs::path determine_home_directory()
else {
home = getenv("HOME");
}
if(home.empty())
if(home.empty()) {
home = "./";
}
return home;
}

Expand All @@ -44,8 +45,13 @@ int main(int argc, char** argv)
.default_http_port = 0
});
app().register_plugin<wallet_api_plugin>();
if(!app().initialize<wallet_plugin, wallet_api_plugin, http_plugin>(argc, argv))
if(!app().initialize<wallet_plugin, wallet_api_plugin, http_plugin>(argc, argv)) {
const auto& opts = app().get_options();
if( opts.count("help") || opts.count("version") || opts.count("full-version") || opts.count("print-default-config") ) {
return 0;
}
return -1;
}
auto& http = app().get_plugin<http_plugin>();
http.add_handler("/v1/" + keosd::config::key_store_executable_name + "/stop", [&a=app()](string, string, url_response_callback cb) { cb(200, fc::variant(fc::variant_object())); a.quit(); } );
app().startup();
Expand Down