From ebf0fe8b8f45a7b37a38783e9ad21736f799667c Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Tue, 13 Feb 2024 18:18:04 +0400 Subject: [PATCH] More predictable Downloader::startDownload() Before this change `Downloader::startDownload()` might avoid starting a new download when a download with the specified URI was already present in its cache. This might be confusing for the following reasons: 1. uri is not the only parameter of `Downloader::startDownload()` - a target download directory may also be specified through the second `options` parameter. Thus calling `Downloader::startDownload()` twice with the same URI but different download directories would not save files into the second directory. 2. Files of a completed download may be removed, whereupon downloading the same files again won't be a no-op. However in such a situation `Downloader` refuses to actually repeat a previous download. --- src/downloader.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/downloader.cpp b/src/downloader.cpp index d874ad89..6f32e6ad 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -169,12 +169,6 @@ std::vector Downloader::getDownloadIds() const { std::shared_ptr Downloader::startDownload(const std::string& uri, const std::vector>& options) { std::unique_lock lock(m_lock); - for (auto& p: m_knownDownloads) { - auto& d = p.second; - auto& uris = d->getUris(); - if (std::find(uris.begin(), uris.end(), uri) != uris.end()) - return d; - } std::vector uris = {uri}; auto gid = mp_aria->addUri(uris, options); m_knownDownloads[gid] = std::make_shared(mp_aria, gid);