From 17f608685d5155ae9d9baa917a1b8345bb4f74d6 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 31 Mar 2020 20:40:03 +0800 Subject: [PATCH] Improve logging for errors This commit also allows the strings to be translated. --- src/base/bittorrent/private/resumedatasavingmanager.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/base/bittorrent/private/resumedatasavingmanager.cpp b/src/base/bittorrent/private/resumedatasavingmanager.cpp index ffe1a6162..3f23376a3 100644 --- a/src/base/bittorrent/private/resumedatasavingmanager.cpp +++ b/src/base/bittorrent/private/resumedatasavingmanager.cpp @@ -44,12 +44,9 @@ void ResumeDataSavingManager::save(const QString &filename, const QByteArray &da const QString filepath = m_resumeDataDir.absoluteFilePath(filename); QSaveFile file {filepath}; - if (file.open(QIODevice::WriteOnly)) { - file.write(data); - if (!file.commit()) { - Logger::instance()->addMessage(QString("Couldn't save data in '%1'. Error: %2") - .arg(filepath, file.errorString()), Log::WARNING); - } + if (!file.open(QIODevice::WriteOnly) || (file.write(data) != data.size()) || !file.commit()) { + LogMsg(tr("Couldn't save data to '%1'. Error: %2") + .arg(filepath, file.errorString()), Log::CRITICAL); } }