Support creating .torrent with larger piece size

Warning: users are at their own discretion to create .torrent with >= 64 MiB piece size as not
every torrent client supports it.
Larger piece sizes are only available when using libtorrent 2.x. libtorrent 1.x is not
efficient with memory usage and in order to avoid user complaints it is limited to 128 MiB.
Also note that, as of this writing, libtorrent 2.0.9 has an internal limitation that only
allows loading maximum 256 MiB piece size. And therefore > 256 MiB size options are forbidden
for now.

Closes #19527.
PR #19535.
This commit is contained in:
Chocobo1 2023-09-03 14:31:32 +08:00 committed by GitHub
parent 2dc1a7d66f
commit 4d2015cfed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 76 deletions

View file

@ -259,12 +259,14 @@ QString Utils::Misc::unitString(const SizeUnit unit, const bool isSpeed)
return ret;
}
QString Utils::Misc::friendlyUnit(const qint64 bytes, const bool isSpeed)
QString Utils::Misc::friendlyUnit(const qint64 bytes, const bool isSpeed, const int precision)
{
const std::optional<SplitToFriendlyUnitResult> result = splitToFriendlyUnit(bytes);
if (!result)
return QCoreApplication::translate("misc", "Unknown", "Unknown (size)");
return Utils::String::fromDouble(result->value, friendlyUnitPrecision(result->unit))
const int digitPrecision = (precision >= 0) ? precision : friendlyUnitPrecision(result->unit);
return Utils::String::fromDouble(result->value, digitPrecision)
+ C_NON_BREAKING_SPACE
+ unitString(result->unit, isSpeed);
}