mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 05:27:15 +03:00
Fix torrent relabeling with unicode names
This commit is contained in:
parent
83d6731fa9
commit
7acfb27a1f
2 changed files with 8 additions and 1 deletions
|
@ -1952,7 +1952,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||
if(h.is_valid()) {
|
||||
// Attempt to remove old folder if empty
|
||||
const QString& old_save_path = TorrentPersistentData::getSavePath(h.hash());
|
||||
const QString new_save_path = QString(p->path.c_str());
|
||||
const QString new_save_path = QString::fromLocal8Bit(p->path.c_str());
|
||||
qDebug("Torrent moved from %s to %s", qPrintable(old_save_path), qPrintable(new_save_path));
|
||||
qDebug("Attempting to remove %s", qPrintable(old_save_path));
|
||||
QDir().rmpath(old_save_path);
|
||||
|
@ -2195,6 +2195,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||
qDebug("getSavePath, got save_path from temp data: %s", qPrintable(savePath));
|
||||
} else {
|
||||
savePath = TorrentPersistentData::getSavePath(hash);
|
||||
qDebug("SavePath got from persistant data is %s", qPrintable(savePath));
|
||||
bool append_root_folder = false;
|
||||
if(savePath.isEmpty()) {
|
||||
if(fromScanDir && m_scanFolders->downloadInTorrentFolder(filePath))
|
||||
|
@ -2212,6 +2213,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||
if(!fromScanDir && appendLabelToSavePath) {
|
||||
const QString &label = TorrentPersistentData::getLabel(hash);
|
||||
if(!label.isEmpty()) {
|
||||
qDebug("Torrent label is %s", qPrintable(label));
|
||||
savePath = misc::updateLabelInSavePath(defaultSavePath, savePath, "", label);
|
||||
}
|
||||
}
|
||||
|
@ -2220,6 +2222,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||
if(!savePath.endsWith(QDir::separator()))
|
||||
savePath += QDir::separator();
|
||||
savePath += root_folder;
|
||||
qDebug("Torrent root folder is %s", qPrintable(root_folder));
|
||||
TorrentPersistentData::saveSavePath(hash, savePath);
|
||||
}
|
||||
qDebug("getSavePath, got save_path from persistent data: %s", qPrintable(savePath));
|
||||
|
@ -2233,6 +2236,8 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||
if(!saveDir.mkpath(saveDir.absolutePath())) {
|
||||
std::cerr << "Couldn't create the save directory: " << qPrintable(saveDir.path()) << "\n";
|
||||
// XXX: Do something else?
|
||||
} else {
|
||||
qDebug("Created save folder at %s", qPrintable(saveDir.path()));
|
||||
}
|
||||
}
|
||||
return savePath;
|
||||
|
|
|
@ -250,6 +250,7 @@ void misc::copyDir(QString src_path, QString dst_path) {
|
|||
|
||||
QString misc::updateLabelInSavePath(const QString& defaultSavePath, QString save_path, const QString old_label, const QString new_label) {
|
||||
if(old_label == new_label) return save_path;
|
||||
qDebug("UpdateLabelInSavePath(%s, %s, %s)", qPrintable(save_path), qPrintable(old_label), qPrintable(new_label));
|
||||
if(!save_path.startsWith(defaultSavePath)) return save_path;
|
||||
QString new_save_path = save_path.replace(defaultSavePath, "");
|
||||
QStringList path_parts = new_save_path.split(QDir::separator(), QString::SkipEmptyParts);
|
||||
|
@ -272,6 +273,7 @@ QString misc::updateLabelInSavePath(const QString& defaultSavePath, QString save
|
|||
new_save_path = defaultSavePath;
|
||||
if(!new_save_path.endsWith(QDir::separator())) new_save_path += QDir::separator();
|
||||
new_save_path += path_parts.join(QDir::separator());
|
||||
qDebug("New save path is %s", qPrintable(new_save_path));
|
||||
return new_save_path;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue