|
|
|
@ -82,6 +82,7 @@
@@ -82,6 +82,7 @@
|
|
|
|
|
#include "base/torrentfileguard.h" |
|
|
|
|
#include "base/torrentfilter.h" |
|
|
|
|
#include "base/unicodestrings.h" |
|
|
|
|
#include "base/utils/bytearray.h" |
|
|
|
|
#include "base/utils/fs.h" |
|
|
|
|
#include "base/utils/misc.h" |
|
|
|
|
#include "base/utils/net.h" |
|
|
|
@ -2088,6 +2089,23 @@ bool Session::addTorrent_impl(CreateTorrentParams params, const MagnetUri &magne
@@ -2088,6 +2089,23 @@ bool Session::addTorrent_impl(CreateTorrentParams params, const MagnetUri &magne
|
|
|
|
|
patchedFastresumeData.replace("6:pausedi0e", "6:pausedi1e"); |
|
|
|
|
patchedFastresumeData.replace("12:auto_managedi0e", "12:auto_managedi1e"); |
|
|
|
|
|
|
|
|
|
// converting relative save_path to absolute
|
|
|
|
|
int start = patchedFastresumeData.indexOf("9:save_path"); |
|
|
|
|
if (start > -1) { |
|
|
|
|
start += 11; |
|
|
|
|
const int end = patchedFastresumeData.indexOf(':', start); |
|
|
|
|
const int len = Utils::ByteArray::midView(patchedFastresumeData, start, (end - start)).toInt(); |
|
|
|
|
if (len > 0) { |
|
|
|
|
const QByteArray relativePath = Utils::ByteArray::midView(patchedFastresumeData, (end + 1), len); |
|
|
|
|
const QByteArray absolutePath = Profile::instance()->fromPortablePath(Utils::Fs::toUniformPath(QString::fromUtf8(relativePath))).toUtf8(); |
|
|
|
|
if (relativePath != absolutePath) { |
|
|
|
|
const QByteArray replaceBefore = "9:save_path" + QByteArray::number(len) + ':' + relativePath; |
|
|
|
|
const QByteArray replaceAfter = "9:save_path" + QByteArray::number(absolutePath.size()) + ':' + absolutePath; |
|
|
|
|
patchedFastresumeData.replace(replaceBefore, replaceAfter); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
p.resume_data = std::vector<char> {patchedFastresumeData.constData() |
|
|
|
|
, (patchedFastresumeData.constData() + patchedFastresumeData.size())}; |
|
|
|
|
p.flags |= lt::add_torrent_params::flag_use_resume_save_path; |
|
|
|
@ -2251,6 +2269,7 @@ bool Session::addTorrent_impl(CreateTorrentParams params, const MagnetUri &magne
@@ -2251,6 +2269,7 @@ bool Session::addTorrent_impl(CreateTorrentParams params, const MagnetUri &magne
|
|
|
|
|
if (params.restored) { // load from existing fastresume
|
|
|
|
|
lt::error_code ec; |
|
|
|
|
p = lt::read_resume_data(fastresumeData, ec); |
|
|
|
|
p.save_path = Profile::instance()->fromPortablePath(Utils::Fs::toUniformPath(fromLTString(p.save_path))).toStdString(); |
|
|
|
|
} |
|
|
|
|
else { // new torrent
|
|
|
|
|
if (!params.hasRootFolder) |
|
|
|
|