mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-30 12:18:05 -06:00
Don't touch torrents whose files are missing (like when their drive isn't plugged in).
Closes #342 #2308 2469.
This commit is contained in:
@@ -245,7 +245,7 @@ TorrentPersistentData::TorrentPersistentData()
|
||||
, dirty(false)
|
||||
{
|
||||
timer.setSingleShot(true);
|
||||
timer.setInterval(5*1000);
|
||||
timer.setInterval(5 * 1000);
|
||||
connect(&timer, SIGNAL(timeout()), SLOT(save()));
|
||||
}
|
||||
|
||||
@@ -264,12 +264,14 @@ void TorrentPersistentData::save()
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
const QVariant TorrentPersistentData::value(const QString &key, const QVariant &defaultValue) const {
|
||||
const QVariant TorrentPersistentData::value(const QString &key, const QVariant &defaultValue) const
|
||||
{
|
||||
QReadLocker locker(&lock);
|
||||
return m_data.value(key, defaultValue);
|
||||
}
|
||||
|
||||
void TorrentPersistentData::setValue(const QString &key, const QVariant &value) {
|
||||
void TorrentPersistentData::setValue(const QString &key, const QVariant &value)
|
||||
{
|
||||
QWriteLocker locker(&lock);
|
||||
if (m_data.value(key) == value)
|
||||
return;
|
||||
@@ -467,6 +469,13 @@ void TorrentPersistentData::saveSeedStatus(const QString &hash, const bool seedS
|
||||
setValue(hash, torrent);
|
||||
}
|
||||
|
||||
void TorrentPersistentData::setHasMissingFiles(const QString& hash, bool missing)
|
||||
{
|
||||
QHash<QString, QVariant> torrent = value(hash).toHash();
|
||||
torrent["has_missing_files"] = missing;
|
||||
setValue(hash, torrent);
|
||||
}
|
||||
|
||||
QString TorrentPersistentData::getSavePath(const QString &hash) const
|
||||
{
|
||||
const QHash<QString, QVariant> torrent = value(hash).toHash();
|
||||
@@ -510,3 +519,9 @@ QString TorrentPersistentData::getMagnetUri(const QString &hash) const
|
||||
Q_ASSERT(torrent.value("is_magnet", false).toBool());
|
||||
return torrent.value("magnet_uri").toString();
|
||||
}
|
||||
|
||||
bool TorrentPersistentData::getHasMissingFiles(const QString& hash)
|
||||
{
|
||||
QHash<QString, QVariant> torrent = value(hash).toHash();
|
||||
return torrent.value("has_missing_files").toBool();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user