mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
Fix encoding error in torrent creator
This commit is contained in:
parent
81cf3782c0
commit
636f9b2912
@ -92,7 +92,7 @@ void TorrentCreatorThread::run() {
|
|||||||
add_files(fs, input_path.toUtf8().constData(), file_filter);
|
add_files(fs, input_path.toUtf8().constData(), file_filter);
|
||||||
#else
|
#else
|
||||||
// Adding files to the torrent
|
// Adding files to the torrent
|
||||||
path full_path = complete(path(input_path.toUtf8().constData()));
|
path full_path = path(input_path.toUtf8().constData());
|
||||||
add_files(fs, full_path, file_filter);
|
add_files(fs, full_path, file_filter);
|
||||||
#endif
|
#endif
|
||||||
if(abort) return;
|
if(abort) return;
|
||||||
@ -125,12 +125,19 @@ void TorrentCreatorThread::run() {
|
|||||||
t.set_priv(is_private);
|
t.set_priv(is_private);
|
||||||
if(abort) return;
|
if(abort) return;
|
||||||
// create the torrent and print it to out
|
// create the torrent and print it to out
|
||||||
ofstream out(complete(path((const char*)save_path.toUtf8())), std::ios_base::binary);
|
qDebug("Saving to %s", qPrintable(save_path));
|
||||||
bencode(std::ostream_iterator<char>(out), t.generate());
|
std::vector<char> torrent;
|
||||||
emit updateProgress(100);
|
bencode(back_inserter(torrent), t.generate());
|
||||||
emit creationSuccess(save_path, parent_path);
|
QFile outfile(save_path);
|
||||||
}
|
if(outfile.open(QIODevice::WriteOnly)) {
|
||||||
catch (std::exception& e){
|
outfile.write(&torrent[0], torrent.size());
|
||||||
emit creationFailure(QString::fromUtf8(e.what()));
|
outfile.close();
|
||||||
|
emit updateProgress(100);
|
||||||
|
emit creationSuccess(save_path, parent_path);
|
||||||
|
} else {
|
||||||
|
throw std::exception(tr("Cannot write the output file").toLocal8Bit().constData());
|
||||||
|
}
|
||||||
|
} catch (std::exception& e){
|
||||||
|
emit creationFailure(QString::fromLocal8Bit(e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user