mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
Save resume data using QSaveFile (Qt5 only)
This commit is contained in:
parent
245f424014
commit
732f46cc69
@ -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)
|
||||
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…
Reference in New Issue
Block a user