Merge pull request #295 from sledgehammer999/optimize_torrent_addittion

Optimize torrent addittion of huge torrents
This commit is contained in:
Christophe Dumez 2012-12-26 11:24:03 -08:00
commit 7fba885d48
2 changed files with 4 additions and 12 deletions

View file

@ -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);

View file

@ -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);