mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-23 01:36:15 +03:00
Fix several problems when incomplete torrent are kept in a temp folder
Bump to rc3
This commit is contained in:
parent
aad42d4a57
commit
121a636b4e
3 changed files with 53 additions and 23 deletions
|
@ -886,9 +886,15 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
|
||||||
torrent_tmp_path += torrent_name;
|
torrent_tmp_path += torrent_name;
|
||||||
}
|
}
|
||||||
p.save_path = torrent_tmp_path.toLocal8Bit().constData();
|
p.save_path = torrent_tmp_path.toLocal8Bit().constData();
|
||||||
qDebug("addMagnetURI: using save_path: %s", qPrintable(defaultTempPath));
|
// Check if save path exists, creating it otherwise
|
||||||
|
if(!QDir(torrent_tmp_path).exists())
|
||||||
|
QDir().mkpath(torrent_tmp_path);
|
||||||
|
qDebug("addMagnetURI: using save_path: %s", qPrintable(torrent_tmp_path));
|
||||||
} else {
|
} else {
|
||||||
p.save_path = savePath.toLocal8Bit().constData();
|
p.save_path = savePath.toLocal8Bit().constData();
|
||||||
|
// Check if save path exists, creating it otherwise
|
||||||
|
if(!QDir(savePath).exists())
|
||||||
|
QDir().mkpath(savePath);
|
||||||
qDebug("addMagnetURI: using save_path: %s", qPrintable(savePath));
|
qDebug("addMagnetURI: using save_path: %s", qPrintable(savePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1130,9 +1136,15 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
|
||||||
torrent_tmp_path += root_folder;
|
torrent_tmp_path += root_folder;
|
||||||
}
|
}
|
||||||
p.save_path = torrent_tmp_path.toLocal8Bit().constData();
|
p.save_path = torrent_tmp_path.toLocal8Bit().constData();
|
||||||
qDebug("addTorrent: using save_path: %s", qPrintable(defaultTempPath));
|
// Check if save path exists, creating it otherwise
|
||||||
|
if(!QDir(torrent_tmp_path).exists())
|
||||||
|
QDir().mkpath(torrent_tmp_path);
|
||||||
|
qDebug("addTorrent: using save_path: %s", qPrintable(torrent_tmp_path));
|
||||||
} else {
|
} else {
|
||||||
p.save_path = savePath.toLocal8Bit().constData();
|
p.save_path = savePath.toLocal8Bit().constData();
|
||||||
|
// Check if save path exists, creating it otherwise
|
||||||
|
if(!QDir(savePath).exists())
|
||||||
|
QDir().mkpath(savePath);
|
||||||
qDebug("addTorrent: using save_path: %s", qPrintable(savePath));
|
qDebug("addTorrent: using save_path: %s", qPrintable(savePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1168,12 +1180,19 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
|
||||||
if(!from_url.isNull()) QFile::remove(file);
|
if(!from_url.isNull()) QFile::remove(file);
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
// Remember root folder
|
||||||
|
TorrentPersistentData::setRootFolder(hash, root_folder);
|
||||||
|
|
||||||
// If temp path is enabled, move torrent
|
// If temp path is enabled, move torrent
|
||||||
if(!defaultTempPath.isEmpty() && !resumed) {
|
/*if(!defaultTempPath.isEmpty() && !resumed) {
|
||||||
qDebug("Temp folder is enabled, moving new torrent to temp folder");
|
qDebug("Temp folder is enabled, moving new torrent to temp folder");
|
||||||
h.move_storage(defaultTempPath);
|
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
|
||||||
}
|
if(!root_folder.isEmpty()) {
|
||||||
|
if(!torrent_tmp_path.endsWith("/")) torrent_tmp_path += "/";
|
||||||
|
torrent_tmp_path += root_folder;
|
||||||
|
}
|
||||||
|
h.move_storage(torrent_tmp_path);
|
||||||
|
}*/
|
||||||
|
|
||||||
// Connections limit per torrent
|
// Connections limit per torrent
|
||||||
h.set_max_connections(Preferences::getMaxConnecsPerTorrent());
|
h.set_max_connections(Preferences::getMaxConnecsPerTorrent());
|
||||||
|
@ -2255,7 +2274,13 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
const QDir current_dir(h.save_path());
|
const QDir current_dir(h.save_path());
|
||||||
const QDir save_dir(getSavePath(h.hash()));
|
const QDir save_dir(getSavePath(h.hash()));
|
||||||
if(current_dir == save_dir) {
|
if(current_dir == save_dir) {
|
||||||
h.move_storage(defaultTempPath);
|
QString root_folder = TorrentPersistentData::getRootFolder(hash);
|
||||||
|
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
|
||||||
|
if(!root_folder.isEmpty()) {
|
||||||
|
if(!torrent_tmp_path.endsWith("/")) torrent_tmp_path += "/";
|
||||||
|
torrent_tmp_path += root_folder;
|
||||||
|
}
|
||||||
|
h.move_storage(torrent_tmp_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit torrentFinishedChecking(h);
|
emit torrentFinishedChecking(h);
|
||||||
|
@ -2347,17 +2372,6 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
}
|
}
|
||||||
// Clean path
|
// Clean path
|
||||||
savePath = misc::expandPath(savePath);
|
savePath = misc::expandPath(savePath);
|
||||||
// Checking if savePath Dir exists
|
|
||||||
// create it if it is not
|
|
||||||
QDir saveDir(savePath);
|
|
||||||
if(!saveDir.exists()) {
|
|
||||||
if(!saveDir.mkpath(saveDir.absolutePath())) {
|
|
||||||
std::cerr << "Couldn't create the save directory: " << qPrintable(saveDir.path()) << "\n";
|
|
||||||
// XXX: Do something else?
|
|
||||||
} else {
|
|
||||||
qDebug("Created save folder at %s", qPrintable(saveDir.path()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return savePath;
|
return savePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
src/src.pro
12
src/src.pro
|
@ -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,14 +12,17 @@ CONFIG += qt \
|
||||||
|
|
||||||
# Update this VERSION for each release
|
# Update this VERSION for each release
|
||||||
os2 {
|
os2 {
|
||||||
DEFINES += VERSION=\'\"v2.3.0rc2\"\'
|
DEFINES += VERSION=\'\"v2.3.0rc3\"\'
|
||||||
} else {
|
} else {
|
||||||
DEFINES += VERSION=\\\"v2.3.0rc2\\\"
|
DEFINES += VERSION=\\\"v2.3.0rc3\\\"
|
||||||
}
|
}
|
||||||
DEFINES += VERSION_MAJOR=2
|
DEFINES += VERSION_MAJOR=2
|
||||||
DEFINES += VERSION_MINOR=3
|
DEFINES += VERSION_MINOR=3
|
||||||
DEFINES += VERSION_BUGFIX=0
|
DEFINES += VERSION_BUGFIX=0
|
||||||
|
|
||||||
|
# NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL
|
||||||
|
DEFINES += VERSION_TYPE=RELEASE_CANDIDATE
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
# Adapt these paths on Windows
|
# Adapt these paths on Windows
|
||||||
INCLUDEPATH += $$quote(C:/qbittorrent/boost_1_42_0)
|
INCLUDEPATH += $$quote(C:/qbittorrent/boost_1_42_0)
|
||||||
|
@ -51,9 +54,6 @@ win32 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL
|
|
||||||
DEFINES += VERSION_TYPE=ALPHA
|
|
||||||
|
|
||||||
# !mac:QMAKE_LFLAGS += -Wl,--as-needed
|
# !mac:QMAKE_LFLAGS += -Wl,--as-needed
|
||||||
contains(DEBUG_MODE, 1) {
|
contains(DEBUG_MODE, 1) {
|
||||||
CONFIG += debug
|
CONFIG += debug
|
||||||
|
|
|
@ -226,6 +226,22 @@ public:
|
||||||
}
|
}
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setRootFolder(QString hash, QString root_folder) {
|
||||||
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
|
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||||
|
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||||
|
data.insert("root_folder", root_folder);
|
||||||
|
all_data[hash] = data;
|
||||||
|
settings.setValue("torrents", all_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static QString getRootFolder(QString hash) {
|
||||||
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
|
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||||
|
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||||
|
return data.value("root_folder", QString()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
static void saveSeedDate(const QTorrentHandle &h) {
|
static void saveSeedDate(const QTorrentHandle &h) {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
|
|
Loading…
Reference in a new issue