mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 14:04:23 +00:00
Pass isAlignmentOptimized flag to piece size calculation
This commit is contained in:
parent
e538eae726
commit
c4625f50a8
@ -157,12 +157,13 @@ void TorrentCreatorThread::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int TorrentCreatorThread::calculateTotalPieces(const QString &inputPath, const int pieceSize)
|
int TorrentCreatorThread::calculateTotalPieces(const QString &inputPath, const int pieceSize, const bool isAlignmentOptimized)
|
||||||
{
|
{
|
||||||
if (inputPath.isEmpty())
|
if (inputPath.isEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
libt::file_storage fs;
|
libt::file_storage fs;
|
||||||
libt::add_files(fs, Utils::Fs::toNativePath(inputPath).toStdString(), fileFilter);
|
libt::add_files(fs, Utils::Fs::toNativePath(inputPath).toStdString(), fileFilter);
|
||||||
return libt::create_torrent(fs, pieceSize).num_pieces();
|
return libt::create_torrent(fs, pieceSize, -1
|
||||||
|
, (isAlignmentOptimized ? libt::create_torrent::optimize_alignment : 0)).num_pieces();
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ namespace BitTorrent
|
|||||||
|
|
||||||
void create(const TorrentCreatorParams ¶ms);
|
void create(const TorrentCreatorParams ¶ms);
|
||||||
|
|
||||||
static int calculateTotalPieces(const QString &inputPath, const int pieceSize);
|
static int calculateTotalPieces(const QString &inputPath, const int pieceSize, const bool isAlignmentOptimized);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void run();
|
void run();
|
||||||
|
@ -215,8 +215,9 @@ void TorrentCreatorDlg::updateProgressBar(int progress)
|
|||||||
void TorrentCreatorDlg::updatePiecesCount()
|
void TorrentCreatorDlg::updatePiecesCount()
|
||||||
{
|
{
|
||||||
const QString path = m_ui->textInputPath->text().trimmed();
|
const QString path = m_ui->textInputPath->text().trimmed();
|
||||||
|
const bool isAlignmentOptimized = m_ui->checkOptimizeAlignment->isChecked();
|
||||||
|
|
||||||
const int count = BitTorrent::TorrentCreatorThread::calculateTotalPieces(path, getPieceSize());
|
const int count = BitTorrent::TorrentCreatorThread::calculateTotalPieces(path, getPieceSize(), isAlignmentOptimized);
|
||||||
m_ui->labelTotalPieces->setText(QString::number(count));
|
m_ui->labelTotalPieces->setText(QString::number(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user