mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-21 07:57:22 -06:00
Use QSaveFile wherever applicable
expected.hpp was fetched from:
b803e3c07b/include/nonstd/expected.hpp
This commit is contained in:
@@ -30,7 +30,8 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMetaObject>
|
||||
#include <QSaveFile>
|
||||
|
||||
#include "base/utils/io.h"
|
||||
|
||||
AsyncFileStorage::AsyncFileStorage(const QString &storageFolderPath, QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -69,10 +70,10 @@ void AsyncFileStorage::store_impl(const QString &fileName, const QByteArray &dat
|
||||
const QString filePath = m_storageDir.absoluteFilePath(fileName);
|
||||
qDebug() << "AsyncFileStorage: Saving data to" << filePath;
|
||||
|
||||
QSaveFile file(filePath);
|
||||
if (!file.open(QIODevice::WriteOnly) || (file.write(data) != data.length()) || !file.commit())
|
||||
const nonstd::expected<void, QString> result = Utils::IO::saveToFile(filePath, data);
|
||||
if (!result)
|
||||
{
|
||||
qDebug() << "AsyncFileStorage: Failed to save data";
|
||||
emit failed(filePath, file.errorString());
|
||||
emit failed(filePath, result.error());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user