Browse Source

Use unique temp directories

Save torrent in temp_path/<torrent_hash> directory.
Closes #5154.
adaptive-webui-19844
Vladimir Golovnev (Glassez) 9 years ago
parent
commit
850556fdfa
  1. 7
      src/base/bittorrent/session.cpp
  2. 1
      src/base/bittorrent/session.h
  3. 4
      src/base/bittorrent/torrenthandle.cpp

7
src/base/bittorrent/session.cpp

@ -331,6 +331,11 @@ QString Session::tempPath() const @@ -331,6 +331,11 @@ QString Session::tempPath() const
return m_tempPath;
}
QString Session::torrentTempPath(const InfoHash &hash) const
{
return m_tempPath + QString(hash) + "/";
}
bool Session::isValidCategoryName(const QString &name)
{
QRegExp re(R"(^([^\\\/]|[^\\\/]([^\\\/]|\/(?=[^\/]))*[^\\\/])$)");
@ -1398,7 +1403,7 @@ bool Session::findIncompleteFiles(TorrentInfo &torrentInfo, QString &savePath) c @@ -1398,7 +1403,7 @@ bool Session::findIncompleteFiles(TorrentInfo &torrentInfo, QString &savePath) c
bool found = findInDir(savePath, torrentInfo);
if (!found && isTempPathEnabled()) {
savePath = m_tempPath;
savePath = torrentTempPath(torrentInfo.hash());
found = findInDir(savePath, torrentInfo);
}

1
src/base/bittorrent/session.h

@ -185,6 +185,7 @@ namespace BitTorrent @@ -185,6 +185,7 @@ namespace BitTorrent
void setTempPath(QString path);
bool isTempPathEnabled() const;
void setTempPathEnabled(bool enabled);
QString torrentTempPath(const InfoHash &hash) const;
static bool isValidCategoryName(const QString &name);
// returns category itself and all top level categories

4
src/base/bittorrent/torrenthandle.cpp

@ -1392,7 +1392,7 @@ void TorrentHandle::handleStorageMovedAlert(libtorrent::storage_moved_alert *p) @@ -1392,7 +1392,7 @@ void TorrentHandle::handleStorageMovedAlert(libtorrent::storage_moved_alert *p)
// Attempt to remove old folder if empty
QDir oldSaveDir(Utils::Fs::fromNativePath(m_oldPath));
if ((oldSaveDir != QDir(m_session->defaultSavePath())) && (oldSaveDir != QDir(m_session->tempPath()))) {
if (oldSaveDir != QDir(m_session->defaultSavePath())) {
qDebug("Attempting to remove %s", qPrintable(m_oldPath));
QDir().rmpath(m_oldPath);
}
@ -1778,7 +1778,7 @@ void TorrentHandle::adjustActualSavePath_impl() @@ -1778,7 +1778,7 @@ void TorrentHandle::adjustActualSavePath_impl()
}
else {
// Moving all downloading torrents to temporary save path
path = m_session->tempPath();
path = m_session->torrentTempPath(hash());
qDebug() << "Moving torrent to its temp save path:" << path;
}

Loading…
Cancel
Save