Browse Source

Some fixes for commit 6dabf50781.

adaptive-webui-19844
sledgehammer999 11 years ago
parent
commit
9a18b50751
  1. 13
      src/qtlibtorrent/qbtsession.cpp
  2. 28
      src/torrentpersistentdata.h

13
src/qtlibtorrent/qbtsession.cpp

@ -80,7 +80,7 @@
//initialize static member variables //initialize static member variables
QHash<QString, TorrentTempData::TorrentData> TorrentTempData::data = QHash<QString, TorrentTempData::TorrentData>(); QHash<QString, TorrentTempData::TorrentData> TorrentTempData::data = QHash<QString, TorrentTempData::TorrentData>();
QHash<QString, TorrentMoveState> TorrentTempData::torrentMoveStates = QHash<QString, TorrentMoveState>(); QHash<QString, TorrentTempData::TorrentMoveState> TorrentTempData::torrentMoveStates = QHash<QString, TorrentTempData::TorrentMoveState>();
QHash<QString, bool> HiddenData::data = QHash<QString, bool>(); QHash<QString, bool> HiddenData::data = QHash<QString, bool>();
unsigned int HiddenData::metadata_counter = 0; unsigned int HiddenData::metadata_counter = 0;
@ -2418,12 +2418,12 @@ void QBtSession::handleStorageMovedAlert(libtorrent::storage_moved_alert* p) {
} }
QString new_save_path = fsutils::fromNativePath(misc::toQStringU(p->path.c_str())); QString new_save_path = fsutils::fromNativePath(misc::toQStringU(p->path.c_str()));
if (new_save_path != TorrentTempData::getNewPath(hash)) { if (new_save_path != fsutils::fromNativePath(TorrentTempData::getNewPath(hash))) {
qWarning("new path received in handleStorageMovedAlert() doesn't match a path in a queue"); qWarning("new path received in handleStorageMovedAlert() doesn't match a path in a queue");
return; return;
} }
QString oldPath = TorrentTempData::getOldPath(hash); QString oldPath = fsutils::fromNativePath(TorrentTempData::getOldPath(hash));
qDebug("Torrent is successfully moved from %s to %s", qPrintable(oldPath), qPrintable(new_save_path)); qDebug("Torrent is successfully moved from %s to %s", qPrintable(oldPath), qPrintable(new_save_path));
@ -2441,7 +2441,7 @@ void QBtSession::handleStorageMovedAlert(libtorrent::storage_moved_alert* p) {
//h.force_recheck(); //h.force_recheck();
QString queued = TorrentTempData::getQueuedPath(hash); QString queued = TorrentTempData::getQueuedPath(hash);
if (queued != QString()) { if (!queued.isEmpty()) {
TorrentTempData::finishMove(hash); TorrentTempData::finishMove(hash);
h.move_storage(queued); h.move_storage(queued);
} }
@ -2465,9 +2465,12 @@ void QBtSession::handleStorageMovedFailedAlert(libtorrent::storage_moved_failed_
return; return;
} }
addConsoleMessage(tr("Could not move torrent: '%1'. Reason: %2").arg(h.name()).arg(misc::toQStringU(p->message())), "red");
QString queued = TorrentTempData::getQueuedPath(hash); QString queued = TorrentTempData::getQueuedPath(hash);
if (queued != QString()) { if (!queued.isEmpty()) {
TorrentTempData::finishMove(hash); TorrentTempData::finishMove(hash);
addConsoleMessage(tr("Attempting to move torrent: '%1' to path: '%2'.").arg(h.name()).arg(fsutils::toNativePath(queued)));
h.move_storage(queued); h.move_storage(queued);
} }
else { else {

28
src/torrentpersistentdata.h

@ -42,20 +42,6 @@
#include "qinisettings.h" #include "qinisettings.h"
#include <QHash> #include <QHash>
struct TorrentMoveState
{
TorrentMoveState(QString oldPath, QString newPath)
: oldPath(oldPath)
, newPath(newPath)
{}
// the moving occurs from oldPath to newPath
// queuedPath is where files should be moved to, when current moving is completed
QString oldPath;
QString newPath;
QString queuedPath;
};
class TorrentTempData { class TorrentTempData {
// This class stores strings w/o modifying separators // This class stores strings w/o modifying separators
public: public:
@ -185,6 +171,20 @@ private:
bool seed; bool seed;
}; };
struct TorrentMoveState
{
TorrentMoveState(QString oldPath, QString newPath)
: oldPath(oldPath)
, newPath(newPath)
{}
// the moving occurs from oldPath to newPath
// queuedPath is where files should be moved to, when current moving is completed
QString oldPath;
QString newPath;
QString queuedPath;
};
static QHash<QString, TorrentData> data; static QHash<QString, TorrentData> data;
static QHash<QString, TorrentMoveState> torrentMoveStates; static QHash<QString, TorrentMoveState> torrentMoveStates;
}; };

Loading…
Cancel
Save