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>
This commit is contained in:
parent
8969070cfd
commit
d14cf6d3d9
@ -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,8 +1062,10 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
|
||||
if (ok) {
|
||||
data.fillFromFindData(findData, false, fname.isDriveRoot());
|
||||
} else {
|
||||
if (!tryFindFallback(fname, data))
|
||||
if (!tryDriveUNCFallback(fname, data)) {
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user