Use QSaveFile wherever applicable

expected.hpp was fetched from:
b803e3c07b/include/nonstd/expected.hpp
This commit is contained in:
Chocobo1 2021-09-05 12:29:32 +08:00
parent 81139c0098
commit 21f72baae2
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
17 changed files with 2597 additions and 88 deletions

View file

@ -49,6 +49,7 @@
#include "base/rss/rss_session.h"
#include "base/utils/compare.h"
#include "base/utils/fs.h"
#include "base/utils/io.h"
#include "base/utils/string.h"
#include "gui/autoexpandabledialog.h"
#include "gui/torrentcategorydialog.h"
@ -452,12 +453,12 @@ void AutomatedRssDownloader::on_exportBtn_clicked()
path += EXT_LEGACY;
}
const QByteArray rules {RSS::AutoDownloader::instance()->exportRules(format)};
QFile file {path};
if (!file.open(QFile::WriteOnly) || (file.write(rules) != rules.length()))
const QByteArray rules = RSS::AutoDownloader::instance()->exportRules(format);
const nonstd::expected<void, QString> result = Utils::IO::saveToFile(path, rules);
if (!result)
{
QMessageBox::critical(this, tr("I/O Error")
, tr("Failed to create the destination file. Reason: %1").arg(file.errorString()));
, tr("Failed to create the destination file. Reason: %1").arg(result.error()));
}
}