mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 00:25:19 +02:00
Dont write directly to files but rather write and copy a tmp file
This commit is contained in:
@@ -105,13 +105,11 @@ bool deleteEntry (ServerListSpec server)
|
||||
}
|
||||
|
||||
std::string path = ServerList::getFilePath();
|
||||
std::ofstream stream (path.c_str());
|
||||
if (stream.is_open())
|
||||
{
|
||||
stream<<ServerList::serialize(serverlist);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
std::ostringstream ss(std::ios_base::binary);
|
||||
ss << ServerList::serialize(serverlist);
|
||||
if (!fs::safeWriteToFile(path, ss.str()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -128,11 +126,9 @@ bool insert (ServerListSpec server)
|
||||
serverlist.insert(serverlist.begin(), server);
|
||||
|
||||
std::string path = ServerList::getFilePath();
|
||||
std::ofstream stream (path.c_str());
|
||||
if (stream.is_open())
|
||||
{
|
||||
stream<<ServerList::serialize(serverlist);
|
||||
}
|
||||
std::ostringstream ss(std::ios_base::binary);
|
||||
ss << ServerList::serialize(serverlist);
|
||||
fs::safeWriteToFile(path, ss.str());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user