Merge pull request #14240 from glassez/drop-ext

Drop extension from generated content folder name
This commit is contained in:
Vladimir Golovnev 2021-01-19 14:59:40 +03:00 committed by GitHub
commit a445311705
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -481,9 +481,17 @@ void TorrentInfo::stripRootFolder()
void TorrentInfo::addRootFolder() void TorrentInfo::addRootFolder()
{ {
const QString rootFolder = name(); const QString originalName = name();
Q_ASSERT(!rootFolder.isEmpty()); Q_ASSERT(!originalName.isEmpty());
const QString extension = Utils::Fs::fileExtension(originalName);
const QString rootFolder = extension.isEmpty()
? originalName
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
: originalName.chopped(extension.size() + 1);
#else
: originalName.left(originalName.size() - (extension.size() + 1));
#endif
const std::string rootPrefix = Utils::Fs::toNativePath(rootFolder + QLatin1Char {'/'}).toStdString(); const std::string rootPrefix = Utils::Fs::toNativePath(rootFolder + QLatin1Char {'/'}).toStdString();
lt::file_storage files = m_nativeInfo->files(); lt::file_storage files = m_nativeInfo->files();
files.set_name(rootFolder.toStdString()); files.set_name(rootFolder.toStdString());