Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
spacey-sooty committed Apr 26, 2024
1 parent 7fbba53 commit 5ec6808
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions ntcore/src/main/native/cpp/NetworkServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ NetworkServer::NetworkServer(std::string_view persistentFilename,
HandleLocal();

// load persistent file first, then initialize
uv::QueueWork(
m_loop, [this] { LoadPersistent(); }, [this] { Init(); });
uv::QueueWork(m_loop, [this] { LoadPersistent(); }, [this] { Init(); });
});
}

Expand Down Expand Up @@ -362,16 +361,8 @@ void NetworkServer::LoadPersistent() {
"(this can be ignored if you aren't expecting persistent values)",
m_persistentFilename, ec.message());
// backup file if it exists
try {
std::filesystem::copy_file(
m_persistentFilename, m_persistentFilename + ".bak",
std::filesystem::copy_options::overwrite_existing);
} catch (const std::filesystem::filesystem_error& e) {
INFO(
"could not backup file '{}': {} "
"(this can be ignored if you aren't expecting persistent values)",
m_persistentFilename, e.code().message());
}
fs::copy_file(m_persistentFilename, m_persistentFilename + ".bak",
std::filesystem::copy_options::overwrite_existing, ec);
// try to write an empty file so it doesn't happen again
wpi::raw_fd_ostream os{m_persistentFilename, ec, fs::F_Text};
if (ec.value() == 0) {
Expand Down

0 comments on commit 5ec6808

Please sign in to comment.