Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
fix corrupted config loading AGAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
Prevter committed Mar 29, 2024
1 parent 966d2ff commit 182ca15
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/shared/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ namespace openhack::config {
return;
}

try {
file >> storage;
storage = nlohmann::json::parse(file, nullptr, false);
if (storage.is_discarded()) {
file.close();
} catch (const nlohmann::json::parse_error &e) {
file.close();
L_WARN("Failed to parse config file: {}", e.what());
L_WARN("Failed to parse config file, creating a new one");
storage = nlohmann::json();
save();
} else {
file.close();
}
}

Expand Down

0 comments on commit 182ca15

Please sign in to comment.