mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Improved previous patch: Force recheck only if we detected that renaming overwrote an existing file
This commit is contained in:
parent
30234a4e78
commit
6a6077bf1d
2 changed files with 10 additions and 3 deletions
|
@ -576,10 +576,11 @@ void PropertiesWidget::renameSelectedFile() {
|
|||
return;
|
||||
}
|
||||
}
|
||||
bool force_recheck = QFile::exists(h.save_path()+QDir::separator()+new_name);
|
||||
qDebug("Renaming %s to %s", old_name.toLocal8Bit().data(), new_name.toLocal8Bit().data());
|
||||
h.rename_file(file_index, new_name);
|
||||
// Force recheck
|
||||
h.force_recheck();
|
||||
if(force_recheck) h.force_recheck();
|
||||
// Rename if torrent files model too
|
||||
if(new_name_last.endsWith(".!qB"))
|
||||
new_name_last.chop(4);
|
||||
|
@ -613,18 +614,21 @@ void PropertiesWidget::renameSelectedFile() {
|
|||
return;
|
||||
}
|
||||
}
|
||||
bool force_recheck = false;
|
||||
// Replace path in all files
|
||||
for(int i=0; i<num_files; ++i) {
|
||||
QString current_name = misc::toQString(h.get_torrent_info().file_at(i).path.string());
|
||||
if(current_name.startsWith(old_path)) {
|
||||
QString new_name = current_name;
|
||||
new_name.replace(0, old_path.length(), new_path);
|
||||
if(!force_recheck && QFile::exists(h.save_path()+QDir::separator()+new_name))
|
||||
force_recheck = true;
|
||||
qDebug("Rename %s to %s", current_name.toLocal8Bit().data(), new_name.toLocal8Bit().data());
|
||||
h.rename_file(i, new_name);
|
||||
}
|
||||
}
|
||||
// Force recheck
|
||||
h.force_recheck();
|
||||
if(force_recheck) h.force_recheck();
|
||||
// Rename folder in torrent files model too
|
||||
PropListModel->setData(index, new_name_last);
|
||||
// Remove old folder
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue