mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-26 06:25:27 +00:00
parent
a2b0531d5f
commit
f00f552369
@ -100,8 +100,6 @@ void TorrentCreatorThread::sendProgressSignal(int currentPieceIdx, int totalPiec
|
|||||||
|
|
||||||
void TorrentCreatorThread::run()
|
void TorrentCreatorThread::run()
|
||||||
{
|
{
|
||||||
const QString creatorStr("qBittorrent " QBT_VERSION);
|
|
||||||
|
|
||||||
emit updateProgress(0);
|
emit updateProgress(0);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -178,17 +176,19 @@ void TorrentCreatorThread::run()
|
|||||||
newTorrent.add_tracker(tracker.trimmed().toStdString(), tier);
|
newTorrent.add_tracker(tracker.trimmed().toStdString(), tier);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInterruptionRequested()) return;
|
|
||||||
|
|
||||||
// calculate the hash for all pieces
|
// calculate the hash for all pieces
|
||||||
lt::set_piece_hashes(newTorrent, Utils::Fs::toNativePath(parentPath).toStdString()
|
lt::set_piece_hashes(newTorrent, Utils::Fs::toNativePath(parentPath).toStdString()
|
||||||
, [this, &newTorrent](const lt::piece_index_t n)
|
, [this, &newTorrent](const lt::piece_index_t n)
|
||||||
{
|
{
|
||||||
|
if (isInterruptionRequested())
|
||||||
|
throw RuntimeError {tr("Create new torrent aborted.")};
|
||||||
|
|
||||||
sendProgressSignal(static_cast<LTUnderlyingType<lt::piece_index_t>>(n), newTorrent.num_pieces());
|
sendProgressSignal(static_cast<LTUnderlyingType<lt::piece_index_t>>(n), newTorrent.num_pieces());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set qBittorrent as creator and add user comment to
|
// Set qBittorrent as creator and add user comment to
|
||||||
// torrent_info structure
|
// torrent_info structure
|
||||||
newTorrent.set_creator(creatorStr.toUtf8().constData());
|
newTorrent.set_creator("qBittorrent " QBT_VERSION);
|
||||||
newTorrent.set_comment(m_params.comment.toUtf8().constData());
|
newTorrent.set_comment(m_params.comment.toUtf8().constData());
|
||||||
// Is private ?
|
// Is private ?
|
||||||
newTorrent.set_priv(m_params.isPrivate);
|
newTorrent.set_priv(m_params.isPrivate);
|
||||||
@ -207,8 +207,7 @@ void TorrentCreatorThread::run()
|
|||||||
QFile outfile {m_params.savePath};
|
QFile outfile {m_params.savePath};
|
||||||
if (!outfile.open(QIODevice::WriteOnly))
|
if (!outfile.open(QIODevice::WriteOnly))
|
||||||
{
|
{
|
||||||
throw RuntimeError
|
throw RuntimeError {tr("Create new torrent file failed. Reason: %1")
|
||||||
{tr("Create new torrent file failed. Reason: %1")
|
|
||||||
.arg(outfile.errorString())};
|
.arg(outfile.errorString())};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,8 +216,7 @@ void TorrentCreatorThread::run()
|
|||||||
lt::bencode(Utils::IO::FileDeviceOutputIterator {outfile}, entry);
|
lt::bencode(Utils::IO::FileDeviceOutputIterator {outfile}, entry);
|
||||||
if (outfile.error() != QFileDevice::NoError)
|
if (outfile.error() != QFileDevice::NoError)
|
||||||
{
|
{
|
||||||
throw RuntimeError
|
throw RuntimeError {tr("Create new torrent file failed. Reason: %1")
|
||||||
{tr("Create new torrent file failed. Reason: %1")
|
|
||||||
.arg(outfile.errorString())};
|
.arg(outfile.errorString())};
|
||||||
}
|
}
|
||||||
outfile.close();
|
outfile.close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user