aboutsummaryrefslogtreecommitdiff
path: root/src/client/QXmppFileSharingManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/QXmppFileSharingManager.cpp')
-rw-r--r--src/client/QXmppFileSharingManager.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/client/QXmppFileSharingManager.cpp b/src/client/QXmppFileSharingManager.cpp
index 30c0ac1e..fc73099c 100644
--- a/src/client/QXmppFileSharingManager.cpp
+++ b/src/client/QXmppFileSharingManager.cpp
@@ -312,13 +312,11 @@ std::shared_ptr<QXmppDownload> QXmppFileSharingManager::downloadFile(
};
fileShare.visitSources([&](const std::any &source) {
- std::type_index index(source.type());
- try {
- download->m_providerDownload = d->providers.at(index)->downloadFile(source, std::move(output), std::move(onProgress), std::move(onFinished));
+ if (auto provider = providerForSource(source)) {
+ download->m_providerDownload = provider->downloadFile(source, std::move(output), std::move(onProgress), std::move(onFinished));
return true;
- } catch (const std::out_of_range &) {
- return false;
}
+ return false;
});
return download;
@@ -329,4 +327,13 @@ void QXmppFileSharingManager::internalRegisterProvider(std::type_index index, st
d->providers.insert_or_assign(index, provider);
}
+std::shared_ptr<QXmppFileSharingProvider> QXmppFileSharingManager::providerForSource(const std::any &source) const
+{
+ if (auto provider = d->providers.find(std::type_index(source.type()));
+ provider != d->providers.cend()) {
+ return provider->second;
+ }
+ return {};
+}
+
#include "QXmppFileSharingManager.moc"