From 7acfb27a1fae0e739042ebecf774f9f486ff8dc1 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 22 Apr 2010 16:19:49 +0000 Subject: [PATCH] Fix torrent relabeling with unicode names --- src/bittorrent.cpp | 7 ++++++- src/misc.cpp | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 30d5b6e28..1827ffa8e 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -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; diff --git a/src/misc.cpp b/src/misc.cpp index e88fc1458..ac518b893 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -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; }