mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 05:08:05 -06:00
Merge pull request #15419 from Chocobo1/file
Improve error detection when saving files
This commit is contained in:
@@ -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,13 +453,12 @@ void AutomatedRssDownloader::on_exportBtn_clicked()
|
||||
path += EXT_LEGACY;
|
||||
}
|
||||
|
||||
QFile file {path};
|
||||
if (!file.open(QFile::WriteOnly)
|
||||
|| (file.write(RSS::AutoDownloader::instance()->exportRules(format)) == -1))
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this, tr("I/O Error")
|
||||
, tr("Failed to create the destination file. Reason: %1").arg(file.errorString()));
|
||||
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(result.error()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user