mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-15 01:33:07 -07:00
parent
facfa26eed
commit
dd1bd8ad10
131 changed files with 2252 additions and 1868 deletions
|
@ -27,37 +27,33 @@
|
|||
*/
|
||||
|
||||
#include "filesearcher.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
#include "base/bittorrent/common.h"
|
||||
#include "base/bittorrent/infohash.h"
|
||||
|
||||
void FileSearcher::search(const BitTorrent::TorrentID &id, const QStringList &originalFileNames
|
||||
, const QString &savePath, const QString &downloadPath)
|
||||
void FileSearcher::search(const BitTorrent::TorrentID &id, const PathList &originalFileNames
|
||||
, const Path &savePath, const Path &downloadPath)
|
||||
{
|
||||
const auto findInDir = [](const QString &dirPath, QStringList &fileNames) -> bool
|
||||
const auto findInDir = [](const Path &dirPath, PathList &fileNames) -> bool
|
||||
{
|
||||
const QDir dir {dirPath};
|
||||
bool found = false;
|
||||
for (QString &fileName : fileNames)
|
||||
for (Path &fileName : fileNames)
|
||||
{
|
||||
if (dir.exists(fileName))
|
||||
if ((dirPath / fileName).exists())
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
else if (dir.exists(fileName + QB_EXT))
|
||||
else if ((dirPath / fileName + QB_EXT).exists())
|
||||
{
|
||||
found = true;
|
||||
fileName += QB_EXT;
|
||||
fileName = fileName + QB_EXT;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
};
|
||||
|
||||
QString usedPath = savePath;
|
||||
QStringList adjustedFileNames = originalFileNames;
|
||||
Path usedPath = savePath;
|
||||
PathList adjustedFileNames = originalFileNames;
|
||||
const bool found = findInDir(usedPath, adjustedFileNames);
|
||||
if (!found && !downloadPath.isEmpty())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue