diff --git a/src/libs/utils/devicefileaccess.cpp b/src/libs/utils/devicefileaccess.cpp index 2ac482977ca..2f1c6632b1e 100644 --- a/src/libs/utils/devicefileaccess.cpp +++ b/src/libs/utils/devicefileaccess.cpp @@ -1044,6 +1044,19 @@ QByteArray UnixDeviceFileAccess::fileId(const FilePath &filePath) const FilePathInfo UnixDeviceFileAccess::filePathInfo(const FilePath &filePath) const { + if (filePath.path() == "/") // TODO: Add FilePath::isRoot() + { + const FilePathInfo r{4096, + FilePathInfo::FileFlags( + FilePathInfo::ReadOwnerPerm | FilePathInfo::WriteOwnerPerm + | FilePathInfo::ExeOwnerPerm | FilePathInfo::ReadGroupPerm + | FilePathInfo::ExeGroupPerm | FilePathInfo::ReadOtherPerm + | FilePathInfo::ExeOtherPerm | FilePathInfo::DirectoryType + | FilePathInfo::LocalDiskFlag | FilePathInfo::ExistsFlag), + QDateTime::currentDateTime()}; + + return r; + } const RunResult stat = runInShell( {"stat", {"-L", "-c", "%f %Y %s", filePath.path()}, OsType::OsTypeLinux}); return FileUtils::filePathInfoFromTriple(QString::fromLatin1(stat.stdOut)); diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 44bf0bab202..efbaf912c6b 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -398,26 +398,30 @@ static FilePath qUrlToFilePath(const QUrl &url) static QUrl filePathToQUrl(const FilePath &filePath) { - return QUrl::fromLocalFile(filePath.toFSPathString()); + return QUrl::fromLocalFile(filePath.toFSPathString()); } void prepareNonNativeDialog(QFileDialog &dialog) { + const auto isValidSideBarPath = [](const FilePath &fp) { + return !fp.needsDevice() || fp.hasFileAccess(); + }; + // Checking QFileDialog::itemDelegate() seems to be the only way to determine // whether the dialog is native or not. if (dialog.itemDelegate()) { FilePaths sideBarPaths; - // Check existing urls, remove paths that need a device and no longer exist. + // Check existing urls, remove paths that need a device and are no longer valid. for (const QUrl &url : dialog.sidebarUrls()) { FilePath path = qUrlToFilePath(url); - if (!path.needsDevice() || path.exists()) + if (isValidSideBarPath(path)) sideBarPaths.append(path); } - // Add all device roots that are not already in the sidebar and exist. + // Add all device roots that are not already in the sidebar and valid. for (const FilePath &path : FSEngine::registeredDeviceRoots()) { - if (!sideBarPaths.contains(path) && path.exists()) + if (!sideBarPaths.contains(path) && isValidSideBarPath(path)) sideBarPaths.append(path); } diff --git a/src/libs/utils/fsengine/fsengine_impl.cpp b/src/libs/utils/fsengine/fsengine_impl.cpp index b0b188b9387..078e16e56bf 100644 --- a/src/libs/utils/fsengine/fsengine_impl.cpp +++ b/src/libs/utils/fsengine/fsengine_impl.cpp @@ -45,6 +45,9 @@ bool FSEngineImpl::open(QIODevice::OpenMode openMode) createCacheData); bool exists = (data.filePathInfo.fileFlags & QAbstractFileEngine::ExistsFlag); + if (data.filePathInfo.fileFlags & QAbstractFileEngine::DirectoryType) + return false; + g_filePathInfoCache.invalidate(m_filePath); ensureStorage(); diff --git a/src/shared/qbs b/src/shared/qbs index 106316f632e..03b0537a79b 160000 --- a/src/shared/qbs +++ b/src/shared/qbs @@ -1 +1 @@ -Subproject commit 106316f632e9aa5673932ea78cbc6ed5b5fe19d0 +Subproject commit 03b0537a79b3050dc0e70b6f4086f513f9b87e6d diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index bab704d1310..665e120f7ba 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -374,24 +374,38 @@ def addBranchWildcardToRoot(rootNode): return rootNode[:pos] + " [[]*[]]" + rootNode[pos:] def openDocument(treeElement): + # split into tree elements + treePathElements = re.split(r"(?