mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 11:49:01 +03:00
parent
669b67e666
commit
7377974731
5 changed files with 16 additions and 15 deletions
|
@ -208,8 +208,7 @@ void CustomDiskIOThread::handleCompleteFiles(lt::storage_index_t storage, const
|
|||
if (filePath.hasExtension(QB_EXT))
|
||||
{
|
||||
const Path incompleteFilePath = savePath / filePath;
|
||||
Path completeFilePath = incompleteFilePath;
|
||||
completeFilePath.removeExtension(QB_EXT);
|
||||
const Path completeFilePath = incompleteFilePath.removedExtension(QB_EXT);
|
||||
if (completeFilePath.exists())
|
||||
{
|
||||
Utils::Fs::removeFile(incompleteFilePath);
|
||||
|
@ -274,8 +273,7 @@ void CustomStorage::handleCompleteFiles(const Path &savePath)
|
|||
if (filePath.hasExtension(QB_EXT))
|
||||
{
|
||||
const Path incompleteFilePath = savePath / filePath;
|
||||
Path completeFilePath = incompleteFilePath;
|
||||
completeFilePath.removeExtension();
|
||||
const Path completeFilePath = incompleteFilePath.removedExtension(QB_EXT);
|
||||
if (completeFilePath.exists())
|
||||
{
|
||||
Utils::Fs::removeFile(incompleteFilePath);
|
||||
|
|
|
@ -294,8 +294,7 @@ TorrentImpl::TorrentImpl(Session *session, lt::session *nativeSession
|
|||
const lt::file_index_t nativeIndex = m_torrentInfo.nativeIndexes().at(i);
|
||||
m_indexMap[nativeIndex] = i;
|
||||
|
||||
Path filePath {fileStorage.file_path(nativeIndex)};
|
||||
filePath.removeExtension(QB_EXT);
|
||||
const auto filePath = Path(fileStorage.file_path(nativeIndex)).removedExtension(QB_EXT);
|
||||
m_filePaths.append(filePath);
|
||||
|
||||
const auto priority = LT::fromNative(filePriorities[LT::toUnderlyingType(nativeIndex)]);
|
||||
|
@ -1520,11 +1519,10 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi
|
|||
{
|
||||
const auto nativeIndex = nativeIndexes.at(i);
|
||||
|
||||
Path filePath = fileNames.at(i);
|
||||
const Path filePath = fileNames.at(i);
|
||||
p.renamed_files[nativeIndex] = filePath.toString().toStdString();
|
||||
|
||||
filePath.removeExtension(QB_EXT);
|
||||
m_filePaths.append(filePath);
|
||||
m_filePaths.append(filePath.removedExtension(QB_EXT));
|
||||
|
||||
const auto priority = LT::fromNative(filePriorities[LT::toUnderlyingType(nativeIndex)]);
|
||||
m_filePriorities.append(priority);
|
||||
|
|
|
@ -151,7 +151,7 @@ QString Path::extension() const
|
|||
return ((dotIndex == -1) ? QString() : filename.mid(dotIndex).toString());
|
||||
}
|
||||
|
||||
bool Path::hasExtension(const QString &ext) const
|
||||
bool Path::hasExtension(const QStringView ext) const
|
||||
{
|
||||
Q_ASSERT(ext.startsWith(u'.') && (ext.size() >= 2));
|
||||
|
||||
|
@ -186,12 +186,17 @@ Path Path::removedExtension() const
|
|||
return createUnchecked(m_pathStr.chopped(extension().size()));
|
||||
}
|
||||
|
||||
void Path::removeExtension(const QString &ext)
|
||||
void Path::removeExtension(const QStringView ext)
|
||||
{
|
||||
if (hasExtension(ext))
|
||||
m_pathStr.chop(ext.size());
|
||||
}
|
||||
|
||||
Path Path::removedExtension(const QStringView ext) const
|
||||
{
|
||||
return (hasExtension(ext) ? createUnchecked(m_pathStr.chopped(ext.size())) : *this);
|
||||
}
|
||||
|
||||
QString Path::data() const
|
||||
{
|
||||
return m_pathStr;
|
||||
|
|
|
@ -58,10 +58,11 @@ public:
|
|||
QString filename() const;
|
||||
|
||||
QString extension() const;
|
||||
bool hasExtension(const QString &ext) const;
|
||||
bool hasExtension(QStringView ext) const;
|
||||
void removeExtension();
|
||||
Path removedExtension() const;
|
||||
void removeExtension(const QString &ext);
|
||||
void removeExtension(QStringView ext);
|
||||
Path removedExtension(QStringView ext) const;
|
||||
|
||||
bool hasAncestor(const Path &other) const;
|
||||
Path relativePathOf(const Path &childPath) const;
|
||||
|
|
|
@ -392,8 +392,7 @@ void SearchPluginManager::pluginDownloadFinished(const Net::DownloadResult &resu
|
|||
{
|
||||
const Path filePath = result.filePath;
|
||||
|
||||
Path pluginPath {QUrl(result.url).path()};
|
||||
pluginPath.removeExtension(); // Remove extension
|
||||
const auto pluginPath = Path(QUrl(result.url).path()).removedExtension();
|
||||
installPlugin_impl(pluginPath.filename(), filePath);
|
||||
Utils::Fs::removeFile(filePath);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue