mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
- Check if the hash read from the filename and from the torrent are the same and don't add it if it is different. Safer
This commit is contained in:
parent
829c358f10
commit
28294efadf
1 changed files with 16 additions and 17 deletions
|
@ -370,27 +370,26 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) {
|
||||||
qDebug(" -> Hash: %s", misc::toString(t.info_hash()).c_str());
|
qDebug(" -> Hash: %s", misc::toString(t.info_hash()).c_str());
|
||||||
qDebug(" -> Name: %s", t.name().c_str());
|
qDebug(" -> Name: %s", t.name().c_str());
|
||||||
QString hash = misc::toQString(t.info_hash());
|
QString hash = misc::toQString(t.info_hash());
|
||||||
|
if(file.startsWith(torrentBackup.path())) {
|
||||||
|
QFileInfo fi(file);
|
||||||
|
QString old_hash = fi.baseName();
|
||||||
|
if(old_hash != hash){
|
||||||
|
qDebug("* ERROR: Strange, hash changed from %s to %s", old_hash.toUtf8().data(), hash.toUtf8().data());
|
||||||
|
QStringList filters;
|
||||||
|
filters << old_hash+".*";
|
||||||
|
QStringList files = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted);
|
||||||
|
QString my_f;
|
||||||
|
foreach(my_f, files) {
|
||||||
|
qDebug("* deleting %s", my_f.toUtf8().data());
|
||||||
|
torrentBackup.remove(my_f);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(s->find_torrent(t.info_hash()).is_valid()) {
|
if(s->find_torrent(t.info_hash()).is_valid()) {
|
||||||
qDebug("/!\\ Torrent is already in download list");
|
qDebug("/!\\ Torrent is already in download list");
|
||||||
// Update info Bar
|
// Update info Bar
|
||||||
if(!fromScanDir) {
|
if(!fromScanDir) {
|
||||||
if(file.startsWith(torrentBackup.path())){
|
|
||||||
// Torrent hash has changed. This should not be possible but...
|
|
||||||
// XXX: Why does this happen sometimes?
|
|
||||||
QFileInfo fi(file);
|
|
||||||
QString old_hash = fi.baseName();
|
|
||||||
qDebug("Strange, hash changed from %s to %s", old_hash.toUtf8().data(), hash.toUtf8().data());
|
|
||||||
Q_ASSERT(old_hash != hash);
|
|
||||||
QStringList filters;
|
|
||||||
filters << old_hash+".*";
|
|
||||||
QStringList files = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted);
|
|
||||||
QString my_f;
|
|
||||||
foreach(my_f, files) {
|
|
||||||
qDebug("* deleting %s", my_f.toUtf8().data());
|
|
||||||
torrentBackup.remove(my_f);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(!from_url.isNull()) {
|
if(!from_url.isNull()) {
|
||||||
// If download from url, remove temp file
|
// If download from url, remove temp file
|
||||||
QFile::remove(file);
|
QFile::remove(file);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue