Skip to content

Commit

Permalink
fix: [workspace]save file in qtcreator issue
Browse files Browse the repository at this point in the history
there is no necessary to filter watcher event when receive a file move event.

Log: fix file disappear issue
Bug: https://pms.uniontech.com/bug-view-213595.html
  • Loading branch information
Lighto-Ku authored and deepin-bot[bot] committed Oct 18, 2023
1 parent 0f4ef16 commit 65b5ee6
Showing 1 changed file with 1 addition and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,26 +178,7 @@ void RootInfo::dofileMoved(const QUrl &fromUrl, const QUrl &toUrl)
if (info)
info->refresh();

if (!containsChild(toUrl)) {
{
// Before the file moved signal is received, `toUrl` may be filtered if it received a created signal
QMutexLocker lk(&watcherEventMutex);
auto iter = std::find_if(watcherEvent.cbegin(), watcherEvent.cend(), [&](const QPair<QUrl, EventType> &event) {
return (UniversalUtils::urlEquals(toUrl, event.first) && event.second == kAddFile);
});
if (iter != watcherEvent.cend())
watcherEvent.removeOne(*iter);
}
dofileCreated(toUrl);
} else {
// if watcherEvent exist toUrl rmevent,cancel this rmevent, beacuse if watcherEvent has toUrl rmevent will bypass this check
QMutexLocker lk(&watcherEventMutex);
auto iter = std::find_if(watcherEvent.cbegin(), watcherEvent.cend(), [&](const QPair<QUrl, EventType> &event) {
return (UniversalUtils::urlEquals(toUrl, event.first) && event.second == kRmFile);
});
if (iter != watcherEvent.cend())
watcherEvent.removeOne(*iter);
}
dofileCreated(toUrl);

// TODO(lanxs) TODO(xust) .hidden file's attribute changed signal not emitted in removable disks (vfat/exfat).
// but renamed from a .goutputstream_xxx file
Expand Down

0 comments on commit 65b5ee6

Please sign in to comment.