diff --git a/include/dfm-io/dfm-io/dfmio_utils.h b/include/dfm-io/dfm-io/dfmio_utils.h index 716b77f..f3979a5 100644 --- a/include/dfm-io/dfm-io/dfmio_utils.h +++ b/include/dfm-io/dfm-io/dfmio_utils.h @@ -58,6 +58,7 @@ class DFMUtils static int syncTrashCount(); static qint64 deviceBytesFree(const QUrl &url); static bool supportTrash(const QUrl &url); + static bool isGvfsFile(const QUrl &url); private: static QMap diff --git a/src/dfm-io/dfm-io/dfmio_utils.cpp b/src/dfm-io/dfm-io/dfmio_utils.cpp index 5f8ab42..b99f77f 100644 --- a/src/dfm-io/dfm-io/dfmio_utils.cpp +++ b/src/dfm-io/dfm-io/dfmio_utils.cpp @@ -334,6 +334,19 @@ bool dfmio::DFMUtils::supportTrash(const QUrl &url) return true; } +bool DFMUtils::isGvfsFile(const QUrl &url) +{ + if (!url.isValid()) + return false; + + const QString &path = url.toLocalFile(); + static const QString gvfsMatch { "(^/run/user/\\d+/gvfs/|^/root/.gvfs/|^/media/[\\s\\S]*/smbmounts)" }; + // TODO(xust) /media/$USER/smbmounts might be changed in the future. + QRegularExpression re { gvfsMatch }; + QRegularExpressionMatch match { re.match(path) }; + return match.hasMatch(); +} + QMap DFMUtils::fstabBindInfo() { static QMutex mutex; diff --git a/src/dfm-io/dfm-io/utils/dlocalhelper.cpp b/src/dfm-io/dfm-io/utils/dlocalhelper.cpp index 37499c9..19a81d0 100644 --- a/src/dfm-io/dfm-io/utils/dlocalhelper.cpp +++ b/src/dfm-io/dfm-io/utils/dlocalhelper.cpp @@ -907,14 +907,17 @@ QSharedPointer DLocalHelper::createSortFileInfo(const if (size > 0) { QString symlinkTagetPath = QString::fromUtf8(buffer, static_cast(size)); sortPointer->symlinkUrl = QUrl::fromLocalFile(symlinkTagetPath); - struct stat st; - if (stat(symlinkTagetPath.toStdString().c_str(),&st) == 0) - sortPointer->isDir = S_ISDIR(st.st_mode); } } else { sortPointer->isDir = S_ISDIR(ent->fts_statp->st_mode); } + if (sortPointer->symlinkUrl.isValid() && !DFMUtils::isGvfsFile(sortPointer->symlinkUrl)) { + struct stat st; + if (stat(sortPointer->symlinkUrl.path().toStdString().c_str(),&st) == 0) + sortPointer->isDir = S_ISDIR(st.st_mode); + } + sortPointer->isFile = !sortPointer->isDir; sortPointer->isHide = name.startsWith(".") ? true : hidList.contains(name); sortPointer->isReadable = ent->fts_statp->st_mode & S_IREAD; diff --git a/src/dfm-io/dfm-io/utils/dlocalhelper.h b/src/dfm-io/dfm-io/utils/dlocalhelper.h index 176ee45..b3c98f8 100644 --- a/src/dfm-io/dfm-io/utils/dlocalhelper.h +++ b/src/dfm-io/dfm-io/utils/dlocalhelper.h @@ -8,6 +8,7 @@ #include #include #include +#include #include