From 9fc7a1bf8530e76f4300d495400bba8a67ab45b1 Mon Sep 17 00:00:00 2001 From: Chris Bessent Date: Sat, 11 Jan 2020 09:24:23 -0700 Subject: Fix downloading files that have no file name Somehow some mods on the Nexus have no file name in certain API responses. Previously, MO assumed the last part of the URL is the file name. This worked until the Nexus started adding URL query stuff to the URL (?md5=xxx). Now, strip out all the URL query stuff to get a valid file name. --- src/downloadmanager.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/downloadmanager.cpp') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 34eebf0c..f5db53bf 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -432,6 +432,13 @@ bool DownloadManager::addDownload(QNetworkReply *reply, const QStringList &URLs, } } + // baseName could be a URL at this point so strip out the URL query + int queryIndex = baseName.indexOf("?"); + if (queryIndex >= 0) + { + baseName.truncate(queryIndex); + } + startDisableDirWatcher(); newDownload->setName(getDownloadFileName(baseName), false); endDisableDirWatcher(); -- cgit v1.3.1