mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-26 19:26:59 +03:00
Fix possible crash when saving fast resume data
This commit is contained in:
parent
9494b15bd5
commit
35f6675d86
2 changed files with 8 additions and 7 deletions
|
@ -871,7 +871,7 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
|
||||||
//Getting fast resume data if existing
|
//Getting fast resume data if existing
|
||||||
std::vector<char> buf;
|
std::vector<char> buf;
|
||||||
if(resumed) {
|
if(resumed) {
|
||||||
const QString fastresume_path = torrentBackup.path()+QDir::separator()+hash+QString(".fastresume");
|
const QString fastresume_path = torrentBackup.absoluteFilePath(hash+QString(".fastresume"));
|
||||||
qDebug("Trying to load fastresume data: %s", qPrintable(fastresume_path));
|
qDebug("Trying to load fastresume data: %s", qPrintable(fastresume_path));
|
||||||
if (load_file(fastresume_path.toLocal8Bit().constData(), buf) == 0) {
|
if (load_file(fastresume_path.toLocal8Bit().constData(), buf) == 0) {
|
||||||
fastResume = true;
|
fastResume = true;
|
||||||
|
@ -1604,9 +1604,10 @@ void Bittorrent::saveFastResumeData() {
|
||||||
const QTorrentHandle h(rd->handle);
|
const QTorrentHandle h(rd->handle);
|
||||||
if(!h.is_valid()) continue;
|
if(!h.is_valid()) continue;
|
||||||
// Remove old fastresume file if it exists
|
// Remove old fastresume file if it exists
|
||||||
QFile::remove(torrentBackup.path()+QDir::separator()+ h.hash() + ".fastresume");
|
const QString file = torrentBackup.absoluteFilePath(h.hash()+".fastresume");
|
||||||
const QString file = h.hash()+".fastresume";
|
if(QFile::exists(file))
|
||||||
boost::filesystem::ofstream out(fs::path(torrentBackup.path().toLocal8Bit().constData()) / file.toLocal8Bit().constData(), std::ios_base::binary);
|
QFile::remove(file);
|
||||||
|
boost::filesystem::ofstream out(boost::filesystem::path(file.toLocal8Bit().constData()), std::ios_base::binary);
|
||||||
out.unsetf(std::ios_base::skipws);
|
out.unsetf(std::ios_base::skipws);
|
||||||
bencode(std::ostream_iterator<char>(out), *rd->resume_data);
|
bencode(std::ostream_iterator<char>(out), *rd->resume_data);
|
||||||
// Remove torrent from session
|
// Remove torrent from session
|
||||||
|
|
|
@ -3,7 +3,7 @@ LANG_PATH = lang
|
||||||
ICONS_PATH = Icons
|
ICONS_PATH = Icons
|
||||||
|
|
||||||
# Set the following variable to 1 to enable debug
|
# Set the following variable to 1 to enable debug
|
||||||
DEBUG_MODE = 1
|
DEBUG_MODE = 0
|
||||||
|
|
||||||
# Global
|
# Global
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
@ -12,9 +12,9 @@ CONFIG += qt \
|
||||||
|
|
||||||
# Update this VERSION for each release
|
# Update this VERSION for each release
|
||||||
os2 {
|
os2 {
|
||||||
DEFINES += VERSION=\'\"v2.3.0rc6\"\'
|
DEFINES += VERSION=\'\"v2.3.0rc7\"\'
|
||||||
} else {
|
} else {
|
||||||
DEFINES += VERSION=\\\"v2.3.0rc6\\\"
|
DEFINES += VERSION=\\\"v2.3.0rc7\\\"
|
||||||
}
|
}
|
||||||
DEFINES += VERSION_MAJOR=2
|
DEFINES += VERSION_MAJOR=2
|
||||||
DEFINES += VERSION_MINOR=3
|
DEFINES += VERSION_MINOR=3
|
||||||
|
|
Loading…
Reference in a new issue