From b236a5a1abccaef2895f6f01577318464d6334b1 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Thu, 30 Sep 2021 17:25:21 +0200 Subject: Workaround for downloading file into the root directory on Windows A bug in QtBase breaks downloading files into a root directory on Windows (eg. C:\): QTBUG-85997 Check if the "non-existent" directory is an existing drive and do not cancel the download in this case. Fixes: QTBUG-96855 Pick-to: 6.2 Change-Id: Icf0e472df723fc4f6ad36f4560509aafa69e3582 Reviewed-by: Allan Sandfeld Jensen --- src/core/download_manager_delegate_qt.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index b7b744603..58f6507a7 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -204,8 +204,16 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem * QFileInfo suggestedFile(info.path); if (info.accepted && !suggestedFile.absoluteDir().mkpath(suggestedFile.absolutePath())) { +#if defined(OS_WIN) + // TODO: Remove this when https://bugreports.qt.io/browse/QTBUG-85997 is fixed. + QDir suggestedDir = QDir(suggestedFile.absolutePath()); + if (!suggestedDir.isRoot() || !suggestedDir.exists()) { +#endif qWarning("Creating download path failed, download cancelled: %s", suggestedFile.absolutePath().toUtf8().data()); info.accepted = false; +#if defined(OS_WIN) + } +#endif } if (!info.accepted) { -- cgit v1.2.3