summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-07-28 11:20:24 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-07-29 20:03:50 +0200
commitd14cf6d3d980e9289d95b197ca46a55e9e263b22 (patch)
treec2b3c5d5e5182e6f49dc9c698f35753617ed76a9 /src
parent8969070cfdeab4502a693bdf46a572cbea50bab3 (diff)
QFileInfo: Fail faster when stat'ing filepath on a disconnected drive
The Windows implementation of QFileSystemEngine tries hard to fill the metadata for a file, even if GetFileAttributesEx returns with error. This is good in many situations, but when the error code indicates that the drive on which the file resides has been disconnected, then we should fail quickly. Task-number: QTBUG-6039 Pick-to: 5.15 Change-Id: I7574c5a2e524e913306d0b470b4f227416442c13 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 4e7824522c..1c99f07400 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -1062,11 +1062,13 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
if (ok) {
data.fillFromFindData(findData, false, fname.isDriveRoot());
} else {
- if (!tryFindFallback(fname, data))
- if (!tryDriveUNCFallback(fname, data)) {
- SetErrorMode(oldmode);
- return false;
- }
+ const DWORD lastError = GetLastError();
+ if (lastError == ERROR_LOGON_FAILURE || lastError == ERROR_BAD_NETPATH // disconnected drive
+ || (!tryFindFallback(fname, data) && !tryDriveUNCFallback(fname, data))) {
+ data.clearFlags();
+ SetErrorMode(oldmode);
+ return false;
+ }
}
SetErrorMode(oldmode);
}