Browse Source

Merge pull request #295 from sledgehammer999/optimize_torrent_addittion

Optimize torrent addittion of huge torrents
adaptive-webui-19844
Christophe Dumez 12 years ago
parent
commit
7fba885d48
  1. 3
      src/previewselect.cpp
  2. 13
      src/qtlibtorrent/qbtsession.cpp

3
src/previewselect.cpp

@ -99,9 +99,10 @@ void PreviewSelect::on_previewButton_clicked() { @@ -99,9 +99,10 @@ void PreviewSelect::on_previewButton_clicked() {
// Flush data
h.flush_cache();
QStringList absolute_paths(h.absolute_files_path());
QString path;
foreach (index, selectedIndexes) {
path = h.absolute_files_path().at(indexes.at(index.row()));
path = absolute_paths.at(indexes.at(index.row()));
// File
if (QFile::exists(path)) {
emit readyToPreviewFile(path);

13
src/qtlibtorrent/qbtsession.cpp

@ -1270,20 +1270,11 @@ void QBtSession::loadTorrentTempData(QTorrentHandle &h, QString savePath, bool m @@ -1270,20 +1270,11 @@ void QBtSession::loadTorrentTempData(QTorrentHandle &h, QString savePath, bool m
// Update file names
const QStringList files_path = TorrentTempData::getFilesPath(hash);
bool force_recheck = false;
QDir base_dir(h.save_path());
if (files_path.size() == h.num_files()) {
for (int i=0; i<h.num_files(); ++i) {
QString old_path = h.absolute_files_path().at(i);
old_path.replace("\\", "/");
if (!QFile::exists(old_path)) {
// Remove old parent folder manually since we will
// not get a file_renamed alert
QStringList parts = old_path.split("/", QString::SkipEmptyParts);
parts.removeLast();
if (!parts.empty())
QDir().rmpath(parts.join("/"));
}
const QString &path = files_path.at(i);
if (!force_recheck && QDir(h.save_path()).exists(path))
if (!force_recheck && base_dir.exists(path))
force_recheck = true;
qDebug("Renaming file to %s", qPrintable(path));
h.rename_file(i, path);

Loading…
Cancel
Save