Skip to content

Commit 0717719

Browse files
committedJan 4, 2019
Player file directory must be only created when using file backend.
Also ensure on each player save that the directory exists
1 parent cf224c9 commit 0717719

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed
 

‎src/database/database-files.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3131
// This backend is intended to be used on Minetest 0.4.16 only for the transition backend
3232
// for player files
3333

34+
PlayerDatabaseFiles::PlayerDatabaseFiles(const std::string &savedir) : m_savedir(savedir)
35+
{
36+
fs::CreateDir(m_savedir);
37+
}
38+
3439
void PlayerDatabaseFiles::serialize(std::ostringstream &os, RemotePlayer *player)
3540
{
3641
// Utilize a Settings object for storing values
@@ -58,6 +63,8 @@ void PlayerDatabaseFiles::serialize(std::ostringstream &os, RemotePlayer *player
5863

5964
void PlayerDatabaseFiles::savePlayer(RemotePlayer *player)
6065
{
66+
fs::CreateDir(m_savedir);
67+
6168
std::string savedir = m_savedir + DIR_DELIM;
6269
std::string path = savedir + player->getName();
6370
bool path_found = false;

‎src/database/database-files.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2929
class PlayerDatabaseFiles : public PlayerDatabase
3030
{
3131
public:
32-
PlayerDatabaseFiles(const std::string &savedir) : m_savedir(savedir) {}
32+
PlayerDatabaseFiles(const std::string &savedir);
3333
virtual ~PlayerDatabaseFiles() = default;
3434

3535
void savePlayer(RemotePlayer *player);

‎src/serverenvironment.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,6 @@ void ServerEnvironment::kickAllPlayers(AccessDeniedCode reason,
544544

545545
void ServerEnvironment::saveLoadedPlayers()
546546
{
547-
std::string players_path = m_path_world + DIR_DELIM + "players";
548-
fs::CreateDir(players_path);
549-
550547
for (RemotePlayer *player : m_players) {
551548
if (player->checkModified() || (player->getPlayerSAO() &&
552549
player->getPlayerSAO()->getMeta().isModified())) {

0 commit comments

Comments
 (0)