Fix possible crash when saving fast resume data

This commit is contained in:
Christophe Dumez 2010-07-21 13:06:09 +00:00
parent 9494b15bd5
commit 35f6675d86
2 changed files with 8 additions and 7 deletions

View file

@ -871,7 +871,7 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
//Getting fast resume data if existing
std::vector<char> buf;
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));
if (load_file(fastresume_path.toLocal8Bit().constData(), buf) == 0) {
fastResume = true;
@ -1604,9 +1604,10 @@ void Bittorrent::saveFastResumeData() {
const QTorrentHandle h(rd->handle);
if(!h.is_valid()) continue;
// Remove old fastresume file if it exists
QFile::remove(torrentBackup.path()+QDir::separator()+ h.hash() + ".fastresume");
const QString file = h.hash()+".fastresume";
boost::filesystem::ofstream out(fs::path(torrentBackup.path().toLocal8Bit().constData()) / file.toLocal8Bit().constData(), std::ios_base::binary);
const QString file = torrentBackup.absoluteFilePath(h.hash()+".fastresume");
if(QFile::exists(file))
QFile::remove(file);
boost::filesystem::ofstream out(boost::filesystem::path(file.toLocal8Bit().constData()), std::ios_base::binary);
out.unsetf(std::ios_base::skipws);
bencode(std::ostream_iterator<char>(out), *rd->resume_data);
// Remove torrent from session

View file

@ -3,7 +3,7 @@ LANG_PATH = lang
ICONS_PATH = Icons
# Set the following variable to 1 to enable debug
DEBUG_MODE = 1
DEBUG_MODE = 0
# Global
TEMPLATE = app
@ -12,9 +12,9 @@ CONFIG += qt \
# Update this VERSION for each release
os2 {
DEFINES += VERSION=\'\"v2.3.0rc6\"\'
DEFINES += VERSION=\'\"v2.3.0rc7\"\'
} else {
DEFINES += VERSION=\\\"v2.3.0rc6\\\"
DEFINES += VERSION=\\\"v2.3.0rc7\\\"
}
DEFINES += VERSION_MAJOR=2
DEFINES += VERSION_MINOR=3