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

Commit

Permalink
Merge pull request #8490 from EOSIO/preemptive-wallet-dir-creation
Browse files Browse the repository at this point in the history
[develop] <wallet_plugin> Preemptively create the wallet directory to prevent exception
  • Loading branch information
John DeBord authored Feb 28, 2020
2 parents ae0c25d + d4e05fd commit 13f6aa8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
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

0 comments on commit 13f6aa8

Please sign in to comment.