mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
- Fix folder renaming (would misbehave under certain conditions)
This commit is contained in:
parent
d5da8a6277
commit
7f576ccc82
2 changed files with 14 additions and 8 deletions
|
@ -613,10 +613,13 @@ void PropertiesWidget::renameSelectedFile() {
|
||||||
// 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());
|
||||||
QString new_name = current_name.replace(old_path, new_path);
|
if(current_name.startsWith(old_path)) {
|
||||||
|
QString new_name = current_name;
|
||||||
|
new_name.replace(0, old_path.length(), new_path);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 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
|
||||||
|
|
|
@ -350,11 +350,14 @@ public slots:
|
||||||
// Replace path in all files
|
// Replace path in all files
|
||||||
for(uint i=0; i<nbFiles; ++i) {
|
for(uint i=0; i<nbFiles; ++i) {
|
||||||
QString current_name = files_path.at(i);
|
QString current_name = files_path.at(i);
|
||||||
QString new_name = current_name.replace(old_path, new_path);
|
if(current_name.startsWith(old_path)) {
|
||||||
|
QString new_name = current_name;
|
||||||
|
new_name.replace(0, old_path.length(), new_path);
|
||||||
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());
|
||||||
// Rename in files_path
|
// Rename in files_path
|
||||||
files_path.replace(i, new_name);
|
files_path.replace(i, new_name);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue