Display error message when unrecoverable error occurred

PR #19462.
This commit is contained in:
Vladimir Golovnev
2023-08-14 16:03:57 +03:00
parent 67d340ad63
commit 2a04a4d077
4 changed files with 47 additions and 21 deletions

View File

@@ -3143,8 +3143,16 @@ void SessionImpl::generateResumeData()
void SessionImpl::saveResumeData()
{
for (const TorrentImpl *torrent : asConst(m_torrents))
torrent->nativeHandle().save_resume_data(lt::torrent_handle::only_if_modified);
m_numResumeData += m_torrents.size();
{
// When the session is terminated due to unrecoverable error
// some of the torrent handles can be corrupted
try
{
torrent->nativeHandle().save_resume_data(lt::torrent_handle::only_if_modified);
++m_numResumeData;
}
catch (const std::exception &) {}
}
// clear queued storage move jobs except the current ongoing one
if (m_moveStorageQueue.size() > 1)

View File

@@ -51,6 +51,7 @@
#include <QStringList>
#include <QUrl>
#include "base/exceptions.h"
#include "base/global.h"
#include "base/logger.h"
#include "base/preferences.h"
@@ -1701,6 +1702,7 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi
}
void TorrentImpl::reload()
try
{
m_completedFiles.fill(false);
m_filesProgress.fill(0);
@@ -1743,6 +1745,11 @@ void TorrentImpl::reload()
updateState();
}
catch (const lt::system_error &err)
{
throw RuntimeError(tr("Failed to reload torrent. Torrent: %1. Reason: %2")
.arg(id().toString(), QString::fromLocal8Bit(err.what())));
}
void TorrentImpl::pause()
{