From 8516a6646e9dc57b909dbbe98e6e1b73180acc2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 30 Jun 2018 01:27:44 +0200 Subject: NOISSUE fix saving the servers.dat file when it doesn't exist yet --- application/pages/instance/ServersPage.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/application/pages/instance/ServersPage.cpp b/application/pages/instance/ServersPage.cpp index 1612ce09..4788e8b0 100644 --- a/application/pages/instance/ServersPage.cpp +++ b/application/pages/instance/ServersPage.cpp @@ -119,6 +119,10 @@ static bool serializeServerDat(const QString& filename, nbt::tag_compound * leve { try { + if(!FS::ensureFilePathExists(filename)) + { + return false; + } std::ostringstream s; nbt::io::write_tag("", *levelInfo, s); QByteArray val(s.str().data(), (int) s.str().size() ); @@ -460,7 +464,8 @@ private slots: void save_internal() { cancelSave(); - qDebug() << "Server list save is performed for" << m_path; + QString path = serversPath(); + qDebug() << "Server list about to be saved to" << path; nbt::tag_compound out; nbt::tag_list list; @@ -472,9 +477,9 @@ private slots: } out.insert("servers", nbt::value(std::move(list))); - if(!serializeServerDat(serversPath(), &out)) + if(!serializeServerDat(path, &out)) { - qDebug() << "Failed to save server list:" << m_path << "Will try again."; + qDebug() << "Failed to save server list:" << path << "Will try again."; scheduleSave(); } } @@ -536,7 +541,7 @@ private: QString serversPath() { QFileInfo foo(FS::PathCombine(m_path, "servers.dat")); - return foo.canonicalFilePath(); + return foo.filePath(); } private: -- cgit v1.2.3