Skip to content
Merged
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
39 changes: 22 additions & 17 deletions src/interactive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,32 @@ int Run(utils::bolt::Config &bolt_config, const std::string &history, bool no_hi
console::SetStdinEcho(true);
}

fs::path history_dir = history;
if (history == (constants::kDefaultHistoryBaseDir + "/" + constants::kDefaultHistoryMemgraphDir)) {
// Fetch home dir for user.
history_dir = utils::GetUserHomeDir() / constants::kDefaultHistoryMemgraphDir;
}
if (!utils::EnsureDir(history_dir)) {
console::EchoFailure("History directory doesn't exist", history_dir.string());
// Should program exit here or just continue with warning message?
cleanup_resources();
return 1;
}
fs::path history_file = history_dir / constants::kHistoryFilename;
// Read history file.
if (fs::exists(history_file)) {
auto ret = replxx_history_load(replxx_instance, history_file.string().c_str());
if (ret != 0) {
console::EchoFailure("Unable to read history file", history_file.string());
// When history is disabled, skip touching the filesystem entirely: don't
// resolve/create the history directory and don't read the history file.
fs::path history_file;
if (!no_history) {
fs::path history_dir = history;
if (history == (constants::kDefaultHistoryBaseDir + "/" + constants::kDefaultHistoryMemgraphDir)) {
// Fetch home dir for user.
history_dir = utils::GetUserHomeDir() / constants::kDefaultHistoryMemgraphDir;
}
if (!utils::EnsureDir(history_dir)) {
console::EchoFailure("History directory doesn't exist", history_dir.string());
// Should program exit here or just continue with warning message?
cleanup_resources();
return 1;
}
history_file = history_dir / constants::kHistoryFilename;
// Read history file.
if (fs::exists(history_file)) {
auto ret = replxx_history_load(replxx_instance, history_file.string().c_str());
if (ret != 0) {
console::EchoFailure("Unable to read history file", history_file.string());
// Should program exit here or just continue with warning message?
cleanup_resources();
return 1;
}
}
}

// Save history function. Used to save replxx history after each query.
Expand Down
Loading