mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-15 09:43:07 -07:00
Don't rewrite TorrentInfo instance if it's valid
This commit is contained in:
parent
953b6fd6f8
commit
389664213b
2 changed files with 9 additions and 22 deletions
|
@ -123,8 +123,10 @@ TorrentHandleImpl::TorrentHandleImpl(Session *session, const lt::torrent_handle
|
||||||
if (m_useAutoTMM)
|
if (m_useAutoTMM)
|
||||||
m_savePath = Utils::Fs::toNativePath(m_session->categorySavePath(m_category));
|
m_savePath = Utils::Fs::toNativePath(m_session->categorySavePath(m_category));
|
||||||
|
|
||||||
|
m_hash = InfoHash {m_nativeHandle.info_hash()};
|
||||||
|
m_torrentInfo = TorrentInfo {m_nativeHandle.torrent_file()};
|
||||||
|
|
||||||
updateStatus();
|
updateStatus();
|
||||||
m_hash = InfoHash(m_nativeStatus.info_hash);
|
|
||||||
|
|
||||||
if (hasMetadata())
|
if (hasMetadata())
|
||||||
{
|
{
|
||||||
|
@ -792,7 +794,7 @@ void TorrentHandleImpl::updateState()
|
||||||
|
|
||||||
bool TorrentHandleImpl::hasMetadata() const
|
bool TorrentHandleImpl::hasMetadata() const
|
||||||
{
|
{
|
||||||
return m_nativeStatus.has_metadata;
|
return m_torrentInfo.isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TorrentHandleImpl::hasMissingFiles() const
|
bool TorrentHandleImpl::hasMissingFiles() const
|
||||||
|
@ -1560,12 +1562,8 @@ void TorrentHandleImpl::handleFastResumeRejectedAlert(const lt::fastresume_rejec
|
||||||
|
|
||||||
void TorrentHandleImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p)
|
void TorrentHandleImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p)
|
||||||
{
|
{
|
||||||
// We don't really need to call updateStatus() in this place.
|
// Remove empty leftover folders
|
||||||
// All we need to do is make sure we have a valid instance of the TorrentInfo object.
|
// For example renaming "a/b/c" to "d/b/c", then folders "a/b" and "a" will
|
||||||
m_torrentInfo = TorrentInfo {m_nativeHandle.torrent_file()};
|
|
||||||
|
|
||||||
// remove empty leftover folders
|
|
||||||
// for example renaming "a/b/c" to "d/b/c", then folders "a/b" and "a" will
|
|
||||||
// be removed if they are empty
|
// be removed if they are empty
|
||||||
const QString oldFilePath = m_oldPath[p->index].takeFirst();
|
const QString oldFilePath = m_oldPath[p->index].takeFirst();
|
||||||
const QString newFilePath = Utils::Fs::toUniformPath(p->new_name());
|
const QString newFilePath = Utils::Fs::toUniformPath(p->new_name());
|
||||||
|
@ -1626,10 +1624,6 @@ void TorrentHandleImpl::handleFileRenameFailedAlert(const lt::file_rename_failed
|
||||||
|
|
||||||
void TorrentHandleImpl::handleFileCompletedAlert(const lt::file_completed_alert *p)
|
void TorrentHandleImpl::handleFileCompletedAlert(const lt::file_completed_alert *p)
|
||||||
{
|
{
|
||||||
// We don't really need to call updateStatus() in this place.
|
|
||||||
// All we need to do is make sure we have a valid instance of the TorrentInfo object.
|
|
||||||
m_torrentInfo = TorrentInfo {m_nativeHandle.torrent_file()};
|
|
||||||
|
|
||||||
qDebug("A file completed download in torrent \"%s\"", qUtf8Printable(name()));
|
qDebug("A file completed download in torrent \"%s\"", qUtf8Printable(name()));
|
||||||
if (m_session->isAppendExtensionEnabled())
|
if (m_session->isAppendExtensionEnabled())
|
||||||
{
|
{
|
||||||
|
@ -1647,8 +1641,10 @@ void TorrentHandleImpl::handleFileCompletedAlert(const lt::file_completed_alert
|
||||||
void TorrentHandleImpl::handleMetadataReceivedAlert(const lt::metadata_received_alert *p)
|
void TorrentHandleImpl::handleMetadataReceivedAlert(const lt::metadata_received_alert *p)
|
||||||
{
|
{
|
||||||
Q_UNUSED(p);
|
Q_UNUSED(p);
|
||||||
|
|
||||||
qDebug("Metadata received for torrent %s.", qUtf8Printable(name()));
|
qDebug("Metadata received for torrent %s.", qUtf8Printable(name()));
|
||||||
updateStatus();
|
m_torrentInfo = TorrentInfo {m_nativeHandle.torrent_file()};
|
||||||
|
|
||||||
if (m_session->isAppendExtensionEnabled())
|
if (m_session->isAppendExtensionEnabled())
|
||||||
manageIncompleteFiles();
|
manageIncompleteFiles();
|
||||||
if (!m_hasRootFolder)
|
if (!m_hasRootFolder)
|
||||||
|
@ -1814,13 +1810,6 @@ lt::torrent_handle TorrentHandleImpl::nativeHandle() const
|
||||||
return m_nativeHandle;
|
return m_nativeHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentHandleImpl::updateTorrentInfo()
|
|
||||||
{
|
|
||||||
if (!hasMetadata()) return;
|
|
||||||
|
|
||||||
m_torrentInfo = TorrentInfo(m_nativeStatus.torrent_file.lock());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TorrentHandleImpl::isMoveInProgress() const
|
bool TorrentHandleImpl::isMoveInProgress() const
|
||||||
{
|
{
|
||||||
return m_storageIsMoving;
|
return m_storageIsMoving;
|
||||||
|
@ -1841,7 +1830,6 @@ void TorrentHandleImpl::updateStatus(const lt::torrent_status &nativeStatus)
|
||||||
m_nativeStatus = nativeStatus;
|
m_nativeStatus = nativeStatus;
|
||||||
|
|
||||||
updateState();
|
updateState();
|
||||||
updateTorrentInfo();
|
|
||||||
|
|
||||||
// NOTE: Don't change the order of these conditionals!
|
// NOTE: Don't change the order of these conditionals!
|
||||||
// Otherwise it will not work properly since torrent can be CheckingDownloading.
|
// Otherwise it will not work properly since torrent can be CheckingDownloading.
|
||||||
|
|
|
@ -250,7 +250,6 @@ namespace BitTorrent
|
||||||
void updateStatus();
|
void updateStatus();
|
||||||
void updateStatus(const lt::torrent_status &nativeStatus);
|
void updateStatus(const lt::torrent_status &nativeStatus);
|
||||||
void updateState();
|
void updateState();
|
||||||
void updateTorrentInfo();
|
|
||||||
|
|
||||||
void handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *p);
|
void handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *p);
|
||||||
void handleFileCompletedAlert(const lt::file_completed_alert *p);
|
void handleFileCompletedAlert(const lt::file_completed_alert *p);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue