Skip to content

Commit

Permalink
Player file directory must be only created when using file backend.
Browse files Browse the repository at this point in the history
Also ensure on each player save that the directory exists
  • Loading branch information
nerzhul committed Jan 4, 2019
1 parent cf224c9 commit 0717719
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/database/database-files.cpp
Expand Up @@ -31,6 +31,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// This backend is intended to be used on Minetest 0.4.16 only for the transition backend
// for player files

PlayerDatabaseFiles::PlayerDatabaseFiles(const std::string &savedir) : m_savedir(savedir)
{
fs::CreateDir(m_savedir);
}

void PlayerDatabaseFiles::serialize(std::ostringstream &os, RemotePlayer *player)
{
// Utilize a Settings object for storing values
Expand Down Expand Up @@ -58,6 +63,8 @@ void PlayerDatabaseFiles::serialize(std::ostringstream &os, RemotePlayer *player

void PlayerDatabaseFiles::savePlayer(RemotePlayer *player)
{
fs::CreateDir(m_savedir);

std::string savedir = m_savedir + DIR_DELIM;
std::string path = savedir + player->getName();
bool path_found = false;
Expand Down
2 changes: 1 addition & 1 deletion src/database/database-files.h
Expand Up @@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class PlayerDatabaseFiles : public PlayerDatabase
{
public:
PlayerDatabaseFiles(const std::string &savedir) : m_savedir(savedir) {}
PlayerDatabaseFiles(const std::string &savedir);
virtual ~PlayerDatabaseFiles() = default;

void savePlayer(RemotePlayer *player);
Expand Down
3 changes: 0 additions & 3 deletions src/serverenvironment.cpp
Expand Up @@ -544,9 +544,6 @@ void ServerEnvironment::kickAllPlayers(AccessDeniedCode reason,

void ServerEnvironment::saveLoadedPlayers()
{
std::string players_path = m_path_world + DIR_DELIM + "players";
fs::CreateDir(players_path);

for (RemotePlayer *player : m_players) {
if (player->checkModified() || (player->getPlayerSAO() &&
player->getPlayerSAO()->getMeta().isModified())) {
Expand Down

0 comments on commit 0717719

Please sign in to comment.