Browse Source

Improved previous patch: Force recheck only if we detected that renaming overwrote an existing file

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
6a6077bf1d
  1. 5
      src/bittorrent.cpp
  2. 8
      src/propertieswidget.cpp

5
src/bittorrent.cpp

@ -1023,13 +1023,16 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
h.set_sequential_download(TorrentTempData::isSequential(hash)); h.set_sequential_download(TorrentTempData::isSequential(hash));
// Import Files names from torrent addition dialog // Import Files names from torrent addition dialog
QStringList files_path = TorrentTempData::getFilesPath(hash); QStringList files_path = TorrentTempData::getFilesPath(hash);
bool force_recheck = false;
if(files_path.size() == h.num_files()) { if(files_path.size() == h.num_files()) {
for(int i=0; i<h.num_files(); ++i) { for(int i=0; i<h.num_files(); ++i) {
QString path = files_path.at(i); QString path = files_path.at(i);
if(!force_recheck && QFile::exists(h.save_path()+QDir::separator()+path))
force_recheck = true;
h.rename_file(i, path); h.rename_file(i, path);
} }
// Force recheck // Force recheck
h.force_recheck(); if(force_recheck) h.force_recheck();
} }
} }
QString label = TorrentTempData::getLabel(hash); QString label = TorrentTempData::getLabel(hash);

8
src/propertieswidget.cpp

@ -576,10 +576,11 @@ void PropertiesWidget::renameSelectedFile() {
return; 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()); qDebug("Renaming %s to %s", old_name.toLocal8Bit().data(), new_name.toLocal8Bit().data());
h.rename_file(file_index, new_name); h.rename_file(file_index, new_name);
// Force recheck // Force recheck
h.force_recheck(); if(force_recheck) h.force_recheck();
// Rename if torrent files model too // Rename if torrent files model too
if(new_name_last.endsWith(".!qB")) if(new_name_last.endsWith(".!qB"))
new_name_last.chop(4); new_name_last.chop(4);
@ -613,18 +614,21 @@ void PropertiesWidget::renameSelectedFile() {
return; return;
} }
} }
bool force_recheck = false;
// Replace path in all files // Replace path in all files
for(int i=0; i<num_files; ++i) { for(int i=0; i<num_files; ++i) {
QString current_name = misc::toQString(h.get_torrent_info().file_at(i).path.string()); QString current_name = misc::toQString(h.get_torrent_info().file_at(i).path.string());
if(current_name.startsWith(old_path)) { if(current_name.startsWith(old_path)) {
QString new_name = current_name; QString new_name = current_name;
new_name.replace(0, old_path.length(), new_path); 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()); qDebug("Rename %s to %s", current_name.toLocal8Bit().data(), new_name.toLocal8Bit().data());
h.rename_file(i, new_name); h.rename_file(i, new_name);
} }
} }
// Force recheck // Force recheck
h.force_recheck(); if(force_recheck) h.force_recheck();
// Rename folder in torrent files model too // Rename folder in torrent files model too
PropListModel->setData(index, new_name_last); PropListModel->setData(index, new_name_last);
// Remove old folder // Remove old folder

Loading…
Cancel
Save