Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: After manually mounting SMB, the network is disconnected and the card is stuck #2095

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,15 @@ void FileOperations::initEventHandle()
static_cast<QString (FileOperationsEventReceiver::*)(const quint64,
const QUrl,
const QUrl,
const QString)>(&FileOperationsEventReceiver::handleOperationTouchFile));
const QString,
const bool)>(&FileOperationsEventReceiver::handleOperationTouchFile));
dpfSignalDispatcher->subscribe(GlobalEventType::kTouchFile,
FileOperationsEventReceiver::instance(),
static_cast<void (FileOperationsEventReceiver::*)(const quint64,
const QUrl,
const QUrl,
const QString,
const bool,
const QVariant,
AbstractJobHandler::OperatorCallback)>(&FileOperationsEventReceiver::handleOperationTouchFile));
dpfSignalDispatcher->subscribe(GlobalEventType::kCreateSymlink,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@
QString handleOperationTouchFile(const quint64 windowId,
const QUrl url,
const QUrl tempUrl,
const QString suffix);
const QString suffix,
const bool isLoadTmp);
void handleOperationTouchFile(const quint64 windowId,
const QUrl url,
const DFMBASE_NAMESPACE::Global::CreateFileType fileType,
Expand All @@ -146,7 +147,8 @@
void handleOperationTouchFile(const quint64 windowId,
const QUrl url,
const QUrl tempUrl,
const QString suffix,

Check warning on line 150 in src/plugins/common/core/dfmplugin-fileoperations/fileoperationsevent/fileoperationseventreceiver.h

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'suffix' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.

Check warning on line 150 in src/plugins/common/core/dfmplugin-fileoperations/fileoperationsevent/fileoperationseventreceiver.h

View workflow job for this annotation

GitHub Actions / static-check / Static-Check

Parameter 'suffix' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.
const bool isLoadTmp,
const QVariant custom,
DFMBASE_NAMESPACE::AbstractJobHandler::OperatorCallback callbackImmediately);

Expand Down Expand Up @@ -225,14 +227,19 @@
DFMBASE_NAMESPACE::AbstractJobHandler::OperatorHandleCallback handle);
bool redo(const quint64 windowId, const QVariantMap &ret,
DFMBASE_NAMESPACE::AbstractJobHandler::OperatorHandleCallback handle);

bool doRenameFiles(const quint64 windowId, const QList<QUrl> &urls,
bool doRenameFiles(QFutureWatcher<bool> *watcher, const QList<QUrl> &urls,
const QPair<QString, QString> &pair,
const QPair<QString, DFMBASE_NAMESPACE::AbstractJobHandler::FileNameAddFlag> &pair2,
const RenameTypes type,
QMap<QUrl, QUrl> &successUrls, QString &errorMsg,
const QVariant custom = QVariant(), DFMBASE_NAMESPACE::AbstractJobHandler::OperatorCallback callback = nullptr);
bool doRenameDesktopFile(const quint64 windowId,
QMap<QUrl, QUrl> &successUrls, QString &errorMsg);
void doRenameFilesByThread(const quint64 windowId,
const QList<QUrl> urls,

Check warning on line 236 in src/plugins/common/core/dfmplugin-fileoperations/fileoperationsevent/fileoperationseventreceiver.h

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'urls' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.

Check warning on line 236 in src/plugins/common/core/dfmplugin-fileoperations/fileoperationsevent/fileoperationseventreceiver.h

View workflow job for this annotation

GitHub Actions / static-check / Static-Check

Parameter 'urls' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.
const QPair<QString, QString> replacePair,
const QPair<QString, DFMBASE_NAMESPACE::AbstractJobHandler::FileNameAddFlag> AddPair,
const RenameTypes type,
const QVariant custom = QVariant(),
DFMBASE_NAMESPACE::AbstractJobHandler::OperatorCallback callback = nullptr);
bool doRenameDesktopFile(QFutureWatcher<bool> *watcher,
const QUrl oldUrl,
const QUrl newUrl,
const DFMBASE_NAMESPACE::AbstractJobHandler::JobFlags flags);
Expand Down Expand Up @@ -263,12 +270,10 @@
QString doTouchFilePremature(const quint64 windowId, const QUrl &url,
const DFMBASE_NAMESPACE::Global::CreateFileType fileType, const QString &suffix,
const QVariant &custom,
DFMBASE_NAMESPACE::AbstractJobHandler::OperatorCallback callbackImmediately);
QString doTouchFilePremature(const quint64 windowId, const QUrl &url,
const QUrl &tempUrl, const QString &suffix,
const QVariant &custom,
DFMBASE_NAMESPACE::AbstractJobHandler::OperatorCallback callbackImmediately);
bool doTouchFilePractically(const quint64 windowId, const QUrl &url, const QUrl &tempUrl = QUrl());
DFMBASE_NAMESPACE::AbstractJobHandler::OperatorCallback callbackImmediately,
const QUrl &tempUrl = QUrl());

void doTouchFilePractically(const quint64 windowId, const QUrl &url, const QUrl &tempUrl = QUrl());
void saveFileOperation(const QList<QUrl> &sourcesUrls, const QList<QUrl> &targetUrls,
DFMBASE_NAMESPACE::GlobalEventType type,
const QList<QUrl> &redoSourcesUrls, const QList<QUrl> &redoTargetUrls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ bool TemplateMenuScene::triggered(QAction *action)
d->windowId,
d->currentDir,
QUrl::fromLocalFile(action->data().toString()),
"");
QString(),
true);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void FileOperatorProxy::touchFile(const CanvasView *view, const QPoint pos, cons
QPair<FileOperatorProxyPrivate::CallBackFunc, QVariant> funcData(FileOperatorProxyPrivate::kCallBackTouchFile, data);
QVariant custom = QVariant::fromValue(funcData);

dpfSignalDispatcher->publish(GlobalEventType::kTouchFile, view->winId(), view->model()->rootUrl(), source, QString(), custom, d->callBack);
dpfSignalDispatcher->publish(GlobalEventType::kTouchFile, view->winId(), view->model()->rootUrl(), source, QString(), true, custom, d->callBack);
}

void FileOperatorProxy::touchFolder(const CanvasView *view, const QPoint pos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void FileOperatorHelper::touchFiles(const FileView *view, const QUrl &source)
url,
source,
QString(),
true,
GlobalEventType::kTouchFile,
callBack);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void FileViewMenuHelper::showEmptyAreaMenu()
dpfSignalDispatcher->publish("dfmplugin_workspace", "signal_ReportLog_MenuData", act->text(), urls);
scene->triggered(act);
}
delete scene;
scene->deleteLater();
}

void FileViewMenuHelper::showNormalMenu(const QModelIndex &index, const Qt::ItemFlags &indexFlags)
Expand Down
44 changes: 8 additions & 36 deletions src/plugins/filemanager/dfmplugin-vault/utils/vaultfilehelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,74 +139,46 @@ bool VaultFileHelper::renameFile(const quint64 windowId, const QUrl oldUrl, cons
}

bool VaultFileHelper::makeDir(const quint64 windowId, const QUrl url,
const QUrl &targetUrl,
const QVariant custom,
AbstractJobHandler::OperatorCallback callback)
{
if (url.scheme() != scheme())
return false;

const QUrl dirUrl = transUrlsToLocal({ url }).first();
if (dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kMkdir, windowId, dirUrl)) {
if (callback) {
AbstractJobHandler::CallbackArgus args(new QMap<AbstractJobHandler::CallbackKey, QVariant>);
args->insert(AbstractJobHandler::CallbackKey::kWindowId, QVariant::fromValue(windowId));
args->insert(AbstractJobHandler::CallbackKey::kSourceUrls, QVariant::fromValue(QList<QUrl>() << url));
args->insert(AbstractJobHandler::CallbackKey::kTargets, QVariant::fromValue(QList<QUrl>() << targetUrl));
args->insert(AbstractJobHandler::CallbackKey::kSuccessed, QVariant::fromValue(true));
args->insert(AbstractJobHandler::CallbackKey::kCustom, custom);
callback(args);
}
}

dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kMkdir, windowId, dirUrl, custom, callback);
return true;
}

bool VaultFileHelper::touchFile(const quint64 windowId,
const QUrl url, const QUrl &targetUrl,
const QUrl url,
const DFMGLOBAL_NAMESPACE::CreateFileType type,
const QString &suffix,
const QVariant &custom, AbstractJobHandler::OperatorCallback callback,
QString *error)
{
Q_UNUSED(error);
if (url.scheme() != scheme())
return false;

const QUrl dirUrl = transUrlsToLocal({ url }).first();
dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kTouchFile, windowId, dirUrl, type, suffix);

if (callback) {
AbstractJobHandler::CallbackArgus args(new QMap<AbstractJobHandler::CallbackKey, QVariant>);
args->insert(AbstractJobHandler::CallbackKey::kWindowId, QVariant::fromValue(windowId));
args->insert(AbstractJobHandler::CallbackKey::kSourceUrls, QVariant::fromValue(QList<QUrl>() << url));
args->insert(AbstractJobHandler::CallbackKey::kTargets, QVariant::fromValue(QList<QUrl>() << targetUrl));
args->insert(AbstractJobHandler::CallbackKey::kCustom, custom);
callback(args);
}
dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kTouchFile, windowId, dirUrl, type, suffix, custom, callback);

return true;
}

bool VaultFileHelper::touchCustomFile(const quint64 windowId, const QUrl url, const QUrl &targetUrl,
const QUrl tempUrl, const QString &suffix,
bool VaultFileHelper::touchCustomFile(const quint64 windowId, const QUrl url,
const QUrl tempUrl, const QString &suffix, const bool isLoadTmp,
const QVariant &custom, AbstractJobHandler::OperatorCallback callback,
QString *error)
{
Q_UNUSED(error);
if (url.scheme() != scheme())
return false;

const QUrl dirUrl = transUrlsToLocal({ url }).first();
dpfSignalDispatcher->publish(DFMBASE_NAMESPACE::GlobalEventType::kTouchFile,
windowId, dirUrl, tempUrl, suffix);

if (callback) {
AbstractJobHandler::CallbackArgus args(new QMap<AbstractJobHandler::CallbackKey, QVariant>);
args->insert(AbstractJobHandler::CallbackKey::kWindowId, QVariant::fromValue(windowId));
args->insert(AbstractJobHandler::CallbackKey::kSourceUrls, QVariant::fromValue(QList<QUrl>() << url));
args->insert(AbstractJobHandler::CallbackKey::kTargets, QVariant::fromValue(QList<QUrl>() << targetUrl));
args->insert(AbstractJobHandler::CallbackKey::kCustom, custom);
callback(args);
}
windowId, dirUrl, tempUrl, suffix, isLoadTmp, custom, callback);

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ class VaultFileHelper : public QObject
bool renameFile(const quint64 windowId, const QUrl oldUrl, const QUrl newUrl,
const DFMBASE_NAMESPACE::AbstractJobHandler::JobFlags flags);
bool makeDir(const quint64 windowId,
const QUrl url, const QUrl &targetUrl,
const QUrl url,
const QVariant custom, DFMBASE_NAMESPACE::AbstractJobHandler::OperatorCallback callback);
bool touchFile(const quint64 windowId,
const QUrl url, const QUrl &targetUrl,
const QUrl url,
const DFMGLOBAL_NAMESPACE::CreateFileType type, const QString &suffix,
const QVariant &custom, DFMBASE_NAMESPACE::AbstractJobHandler::OperatorCallback callback,
QString *error);
bool touchCustomFile(const quint64 windowId, const QUrl url, const QUrl &targetUrl,
bool touchCustomFile(const quint64 windowId, const QUrl url,
const QUrl tempUrl,
const QString &suffix, const QVariant &custom,
const QString &suffix, const bool isLoadTmp, const QVariant &custom,
DFMBASE_NAMESPACE::AbstractJobHandler::OperatorCallback callback, QString *error);
bool writeUrlsToClipboard(const quint64 windowId, const DFMBASE_NAMESPACE::ClipBoard::ClipboardAction action,
const QList<QUrl> urls);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ TEST_F(UT_FileOperationsEventReceiver, testHandleOperationTouchFile)
EXPECT_TRUE(op != nullptr);
QUrl url = QUrl::fromLocalFile(QDir::currentPath());
EXPECT_TRUE(op->handleOperationTouchFile(0, QUrl(), Global::CreateFileType::kCreateFileTypeText, QString()).isEmpty());
EXPECT_TRUE(op->handleOperationTouchFile(0, QUrl(), url, QString()).isEmpty());
EXPECT_TRUE(op->handleOperationTouchFile(0, QUrl(), url, QString(), true).isEmpty());
AbstractJobHandler::OperatorCallback callback = [](const AbstractJobHandler::CallbackArgus){};
EXPECT_NO_FATAL_FAILURE(op->handleOperationTouchFile(0, QUrl(), Global::CreateFileType::kCreateFileTypeText, QString(), QVariant(), callback));
EXPECT_NO_FATAL_FAILURE(op->handleOperationTouchFile(0, QUrl(), url, QString(), QVariant(), callback));
EXPECT_NO_FATAL_FAILURE(op->handleOperationTouchFile(0, QUrl(), url, QString(), true, QVariant(), callback));

stub_ext::StubExt stub;
stub.set_lamda(&DialogManager::showErrorDialog,[]{});
Expand All @@ -227,7 +227,7 @@ TEST_F(UT_FileOperationsEventReceiver, testHandleOperationTouchFile)
auto publishFun = static_cast<PublishFun>(&EventDispatcherManager::publish);
stub.set_lamda(publishFun, [] {return true;});
EXPECT_TRUE(op->handleOperationTouchFile(0, url, Global::CreateFileType::kCreateFileTypeText, QString()).isEmpty());
EXPECT_TRUE(op->handleOperationTouchFile(0, url, QUrl(), QString()).isEmpty());
EXPECT_TRUE(op->handleOperationTouchFile(0, url, QUrl(), QString(), true).isEmpty());

stub.set_lamda(&FileUtils::isLocalFile,[]{ return false; });
typedef bool (EventSequenceManager::*RunFunc)(const QString &, const QString &, quint64, const QUrl &, QUrl &,
Expand All @@ -236,7 +236,7 @@ TEST_F(UT_FileOperationsEventReceiver, testHandleOperationTouchFile)
auto runFunc = static_cast<RunFunc>(&EventSequenceManager::run);
stub.set_lamda(runFunc, [] {return true;});
EXPECT_TRUE(op->handleOperationTouchFile(0, url, Global::CreateFileType::kCreateFileTypeText, QString()).isEmpty());
EXPECT_TRUE(op->handleOperationTouchFile(0, url, QUrl(), QString()).isEmpty());
EXPECT_TRUE(op->handleOperationTouchFile(0, url, QUrl(), QString(), true).isEmpty());
}

TEST_F(UT_FileOperationsEventReceiver, testHandleOperationLinkFile)
Expand Down Expand Up @@ -602,7 +602,7 @@ TEST_F(UT_FileOperationsEventReceiver, testDoTouchFilePractically)
typedef bool (EventDispatcherManager::*PublishFun)(dpf::EventType, quint64, QList<QUrl> &, bool &, QString &);
auto publishFun = static_cast<PublishFun>(&EventDispatcherManager::publish);
stub.set_lamda(publishFun, [] {return false;});
EXPECT_FALSE(op->doTouchFilePractically(0, url, QUrl()));
EXPECT_NO_FATAL_FAILURE(op->doTouchFilePractically(0, url, QUrl()));
}

TEST_F(UT_FileOperationsEventReceiver, testDoTouchFilePremature)
Expand All @@ -611,7 +611,7 @@ TEST_F(UT_FileOperationsEventReceiver, testDoTouchFilePremature)
EXPECT_TRUE(op != nullptr);
QUrl url = QUrl::fromLocalFile(QDir::currentPath());
stub_ext::StubExt stub;
stub.set_lamda(&FileOperationsEventReceiver::doTouchFilePractically,[]{return false;});
stub.set_lamda(&FileOperationsEventReceiver::doTouchFilePractically,[]{return;});
AbstractJobHandler::OperatorCallback callback = [](const AbstractJobHandler::CallbackArgus){};
EXPECT_TRUE(op->doTouchFilePremature(0, QUrl(), Global::CreateFileType::kCreateFileTypeText, "", QVariant(), callback).isEmpty());

Expand All @@ -637,11 +637,11 @@ TEST_F(UT_FileOperationsEventReceiver, testDoTouchFilePremature1)
EXPECT_TRUE(op != nullptr);
QUrl url = QUrl::fromLocalFile(QDir::currentPath());
stub_ext::StubExt stub;
stub.set_lamda(&FileOperationsEventReceiver::doTouchFilePractically,[]{return false;});
stub.set_lamda(&FileOperationsEventReceiver::doTouchFilePractically,[]{return;});
AbstractJobHandler::OperatorCallback callback = [](const AbstractJobHandler::CallbackArgus){};
EXPECT_TRUE(op->doTouchFilePremature(0, QUrl(), url, "", QVariant(), callback).isEmpty());
EXPECT_TRUE(op->doTouchFilePremature(0, QUrl(), Global::CreateFileType::kCreateFileTypeUnknow, "", QVariant(), callback, url).isEmpty());

EXPECT_TRUE(op->doTouchFilePremature(0, url, url, "", QVariant(), callback).isEmpty());
EXPECT_TRUE(op->doTouchFilePremature(0, url, Global::CreateFileType::kCreateFileTypeUnknow, "", QVariant(), callback, url).isEmpty());

stub.set_lamda(&FileUtils::isLocalFile, []{return false;});
typedef bool (EventSequenceManager::*RunFunc)(const QString &, const QString &, quint64, const QUrl &, QUrl &, const QUrl &,
Expand All @@ -652,7 +652,7 @@ TEST_F(UT_FileOperationsEventReceiver, testDoTouchFilePremature1)
typedef bool (EventDispatcherManager::*PublishFun1)(dpf::EventType, quint64, QList<QUrl> &, bool &&, QString &);
auto publishFun1 = static_cast<PublishFun1>(&EventDispatcherManager::publish);
stub.set_lamda(publishFun1, [] {return false;});
EXPECT_TRUE(!op->doTouchFilePremature(0, url, url, "", QVariant(), callback).isEmpty());
EXPECT_TRUE(!op->doTouchFilePremature(0, url, Global::CreateFileType::kCreateFileTypeUnknow, "", QVariant(), callback, url).isEmpty());

op->handleOperationCleanSaveOperationsStack();
}
Loading
Loading