Skip to content

Commit

Permalink
fix: The mounted Samba network disk prompts that the file has been mo…
Browse files Browse the repository at this point in the history
…ved or deleted after the user changes their password

When checking file information, if the host is down and can be accessed, a prompt box will pop up

Log: The mounted Samba network disk prompts that the file has been moved or deleted after the user changes their password
Bug: https://pms.uniontech.com/bug-view-261605.html
  • Loading branch information
liyigang1 committed Jul 10, 2024
1 parent 68027cc commit 54f042d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/dfm-base/file/local/asyncfileinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,14 @@ bool AsyncFileInfo::asyncQueryDfmFileInfo(int ioPriority, FileInfo::initQuerierA
return true;
}

QString AsyncFileInfo::errorString()
{
auto dFileInfo = d->dfmFileInfo;
if (dFileInfo)
return dFileInfo->lastError().errorMsg();
return QString();
}

void AsyncFileInfoPrivate::init(const QUrl &url, QSharedPointer<DFMIO::DFileInfo> dfileInfo)
{
mimeTypeMode = QMimeDatabase::MatchDefault;
Expand Down
1 change: 1 addition & 0 deletions src/dfm-base/file/local/asyncfileinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class AsyncFileInfo : public FileInfo
// less 0,cache fialed, equeal 0,another cache, bigger 0 cache success
int cacheAsyncAttributes();
bool asyncQueryDfmFileInfo(int ioPriority = 0, initQuerierAsyncCallback func = nullptr, void *userData = nullptr);
QString errorString();
};
}
typedef QSharedPointer<DFMBASE_NAMESPACE::AsyncFileInfo> DFMAsyncFileInfoPointer;
Expand Down
10 changes: 8 additions & 2 deletions src/dfm-base/utils/fileinfohelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <dfm-base/file/local/asyncfileinfo.h>
#include <dfm-base/utils/fileutils.h>
#include <dfm-base/utils/networkutils.h>
#include <dfm-base/base/device/deviceutils.h>

#include <QGuiApplication>
#include <QTimer>
Expand Down Expand Up @@ -139,11 +141,15 @@ void FileInfoHelper::handleFileRefresh(QSharedPointer<FileInfo> dfileInfo)
if (!asyncInfo)
return;

auto callback = [asyncInfo](bool success, void *data) {
auto callback = [asyncInfo, this](bool success, void *data) {
Q_UNUSED(data);
if (!success) {
qCWarning(logDFMBase) << "Failed to query file information asynchronously! url = " << asyncInfo->fileUrl();
FileInfoHelper::instance().checkInfoRefresh(asyncInfo);
if (DeviceUtils::isSamba(asyncInfo->fileUrl())
&& asyncInfo->errorString().contains(QObject::tr("Host is down"))
&& !NetworkUtils::instance()->checkFtpOrSmbBusy(asyncInfo->fileUrl())) {
emit this->smbSeverMayModifyPassword(asyncInfo->fileUrl());
}
return;
}
FileInfoHelper::instance().cacheFileInfoByThread(asyncInfo);
Expand Down
1 change: 1 addition & 0 deletions src/dfm-base/utils/fileinfohelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class FileInfoHelper : public QObject
// 第二个参数表示,当前是链接文件的原文件更新完成
void fileRefreshFinished(const QUrl url, const QString &infoPtr, const bool isLinkOrg);
void fileRefreshRequest(QSharedPointer<FileInfo> dfileInfo);
void smbSeverMayModifyPassword(const QUrl &url);
private Q_SLOTS:
void aboutToQuit();
void handleFileRefresh(QSharedPointer<FileInfo> dfileInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include <dfm-base/utils/dialogmanager.h>
#include <dfm-base/widgets/filemanagerwindowsmanager.h>
#include <dfm-base/base/configs/dconfig/dconfigmanager.h>
#include <dfm-base/utils/fileinfohelper.h>
#include <dfm-base/base/device/deviceutils.h>

#ifdef DTKWIDGET_CLASS_DSizeMode
# include <DSizeMode>
Expand Down Expand Up @@ -1915,6 +1917,18 @@ void FileView::initializeConnect()
},
Qt::DirectConnection);
}
connect(&FileInfoHelper::instance(), &FileInfoHelper::smbSeverMayModifyPassword, this, [this](const QUrl &url){
if (DeviceUtils::isSamba(rootUrl()) && url.path().startsWith(rootUrl().path())) {
qInfo() << rootUrl() << url << "smb server may modify password";
if (d->isShowSmbMountError)
return ;
d->isShowSmbMountError = true;
DialogManager::instance()->showErrorDialog(tr("Mount error"),
tr("SMB server login credentials are invalid. Please uninstall and remount"));
d->isShowSmbMountError = false;
}

});
}

void FileView::initializeScrollBarWatcher()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class FileViewPrivate
QRect mouseMoveRect { QRect(-1, -1, 1, 1) };

bool itemsExpandable { false };
std::atomic_bool isShowSmbMountError { false };

explicit FileViewPrivate(FileView *qq);
int iconModeColumnCount(int itemWidth = 0) const;
Expand Down

0 comments on commit 54f042d

Please sign in to comment.