mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[ntcore] Backup persistent file if it fails to parse (#6523)
This commit is contained in:
@@ -359,6 +359,9 @@ void NetworkServer::LoadPersistent() {
|
||||
"could not open persistent file '{}': {} "
|
||||
"(this can be ignored if you aren't expecting persistent values)",
|
||||
m_persistentFilename, ec.message());
|
||||
// backup file
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user