Browse Source

Save resume data using QSaveFile (Qt5 only)

adaptive-webui-19844
Vladimir Golovnev (Glassez) 9 years ago
parent
commit
732f46cc69
  1. 18
      src/base/bittorrent/private/resumedatasavingmanager.cpp

18
src/base/bittorrent/private/resumedatasavingmanager.cpp

@ -27,8 +27,13 @@ @@ -27,8 +27,13 @@
*/
#include <QDebug>
#ifdef QBT_USES_QT5
#include <QSaveFile>
#else
#include <QFile>
#endif
#include "base/logger.h"
#include "base/utils/fs.h"
#include "resumedatasavingmanager.h"
@ -43,7 +48,18 @@ void ResumeDataSavingManager::saveResumeData(QString infoHash, QByteArray data) @@ -43,7 +48,18 @@ void ResumeDataSavingManager::saveResumeData(QString infoHash, QByteArray data)
QString filepath = m_resumeDataDir.absoluteFilePath(filename);
qDebug() << "Saving resume data in" << filepath;
#ifdef QBT_USES_QT5
QSaveFile resumeFile(filepath);
#else
QFile resumeFile(filepath);
if (resumeFile.open(QIODevice::WriteOnly))
#endif
if (resumeFile.open(QIODevice::WriteOnly)) {
resumeFile.write(data);
#ifdef QBT_USES_QT5
if (!resumeFile.commit()) {
Logger::instance()->addMessage(QString("Couldn't save resume data in %1. Error: %2")
.arg(filepath).arg(resumeFile.errorString()), Log::WARNING);
}
#endif
}
}

Loading…
Cancel
Save