|
|
|
@ -294,31 +294,35 @@ QString TorrentHandle::currentTracker() const
@@ -294,31 +294,35 @@ QString TorrentHandle::currentTracker() const
|
|
|
|
|
return Utils::String::fromStdString(m_nativeStatus.current_tracker); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString TorrentHandle::savePath() const |
|
|
|
|
QString TorrentHandle::savePath(bool actual) const |
|
|
|
|
{ |
|
|
|
|
return Utils::Fs::fromNativePath(m_savePath); |
|
|
|
|
if (actual) |
|
|
|
|
return Utils::Fs::fromNativePath(nativeActualSavePath()); |
|
|
|
|
else |
|
|
|
|
return Utils::Fs::fromNativePath(m_savePath); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString TorrentHandle::rootPath() const |
|
|
|
|
QString TorrentHandle::rootPath(bool actual) const |
|
|
|
|
{ |
|
|
|
|
if (filesCount() > 1) { |
|
|
|
|
QString first_filepath = filePath(0); |
|
|
|
|
const int slashIndex = first_filepath.indexOf("/"); |
|
|
|
|
if (slashIndex >= 0) |
|
|
|
|
return QDir(actualSavePath()).absoluteFilePath(first_filepath.left(slashIndex)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return actualSavePath(); |
|
|
|
|
QString firstFilePath = filePath(0); |
|
|
|
|
const int slashIndex = firstFilePath.indexOf("/"); |
|
|
|
|
if (slashIndex >= 0) |
|
|
|
|
return QDir(savePath(actual)).absoluteFilePath(firstFilePath.left(slashIndex)); |
|
|
|
|
else |
|
|
|
|
return QDir(savePath(actual)).absoluteFilePath(firstFilePath); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString TorrentHandle::nativeActualSavePath() const |
|
|
|
|
QString TorrentHandle::contentPath(bool actual) const |
|
|
|
|
{ |
|
|
|
|
return Utils::String::fromStdString(m_nativeStatus.save_path); |
|
|
|
|
if (filesCount() == 1) |
|
|
|
|
return QDir(savePath(actual)).absoluteFilePath(filePath(0)); |
|
|
|
|
else |
|
|
|
|
return rootPath(actual); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString TorrentHandle::actualSavePath() const |
|
|
|
|
QString TorrentHandle::nativeActualSavePath() const |
|
|
|
|
{ |
|
|
|
|
return Utils::Fs::fromNativePath(nativeActualSavePath()); |
|
|
|
|
return Utils::String::fromStdString(m_nativeStatus.save_path); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QList<TrackerEntry> TorrentHandle::trackers() const |
|
|
|
@ -530,7 +534,7 @@ QStringList TorrentHandle::absoluteFilePaths() const
@@ -530,7 +534,7 @@ QStringList TorrentHandle::absoluteFilePaths() const
|
|
|
|
|
{ |
|
|
|
|
if (!hasMetadata()) return QStringList(); |
|
|
|
|
|
|
|
|
|
QDir saveDir(actualSavePath()); |
|
|
|
|
QDir saveDir(savePath(true)); |
|
|
|
|
QStringList res; |
|
|
|
|
for (int i = 0; i < filesCount(); ++i) |
|
|
|
|
res << Utils::Fs::expandPathAbs(saveDir.absoluteFilePath(filePath(i))); |
|
|
|
@ -541,7 +545,7 @@ QStringList TorrentHandle::absoluteFilePathsUnwanted() const
@@ -541,7 +545,7 @@ QStringList TorrentHandle::absoluteFilePathsUnwanted() const
|
|
|
|
|
{ |
|
|
|
|
if (!hasMetadata()) return QStringList(); |
|
|
|
|
|
|
|
|
|
QDir saveDir(actualSavePath()); |
|
|
|
|
QDir saveDir(savePath(true)); |
|
|
|
|
QStringList res; |
|
|
|
|
std::vector<int> fp; |
|
|
|
|
SAFE_GET(fp, file_priorities); |
|
|
|
@ -1486,7 +1490,7 @@ void TorrentHandle::handleFileRenamedAlert(libtorrent::file_renamed_alert *p)
@@ -1486,7 +1490,7 @@ void TorrentHandle::handleFileRenamedAlert(libtorrent::file_renamed_alert *p)
|
|
|
|
|
QString newPath = newPathParts.join("/"); |
|
|
|
|
if (!newPathParts.isEmpty() && (oldPath != newPath)) { |
|
|
|
|
qDebug("oldPath(%s) != newPath(%s)", qPrintable(oldPath), qPrintable(newPath)); |
|
|
|
|
oldPath = QString("%1/%2").arg(actualSavePath()).arg(oldPath); |
|
|
|
|
oldPath = QString("%1/%2").arg(savePath(true)).arg(oldPath); |
|
|
|
|
qDebug("Detected folder renaming, attempt to delete old folder: %s", qPrintable(oldPath)); |
|
|
|
|
QDir().rmpath(oldPath); |
|
|
|
|
} |
|
|
|
@ -1781,7 +1785,7 @@ void TorrentHandle::prioritizeFiles(const QVector<int> &priorities)
@@ -1781,7 +1785,7 @@ void TorrentHandle::prioritizeFiles(const QVector<int> &priorities)
|
|
|
|
|
SAFE_CALL(prioritize_files, priorities.toStdVector()); |
|
|
|
|
|
|
|
|
|
qDebug() << Q_FUNC_INFO << "Moving unwanted files to .unwanted folder and conversely..."; |
|
|
|
|
QString spath = actualSavePath(); |
|
|
|
|
QString spath = savePath(true); |
|
|
|
|
for (int i = 0; i < priorities.size(); ++i) { |
|
|
|
|
QString filepath = filePath(i); |
|
|
|
|
// Move unwanted files to a .unwanted subfolder
|
|
|
|
|