尝试修复添加文件到watcher提示成功但实际失败问题

如果一个文件被从文件系统中删除,会出现缓存没有清空的情况,尝试在IGNORE流程中强行情况缓存以解决此问题
This commit is contained in:
Yue-Lan 2024-05-20 12:02:18 +08:00 committed by shaozhimin
parent db9df55d1a
commit e608a189a5
1 changed files with 8 additions and 1 deletions

View File

@ -376,7 +376,13 @@ void FileWatcher::sendSignal(int wfd, QString name, int mask)
lock.release();
this->listLocker.unlock();
this->removeWatchFile(path);
int result = this->removeWatchFile(path);
if (result) {
// 即使失败也需要清wfd空缓存否则下一次添加会继续失败
this->fdCacheMap.remove(watchList[path].wfd);
this->watchList.remove(path);
this->listLocker.unlock();
}
}
if (mask & IN_UNMOUNT)
{
@ -419,6 +425,7 @@ int FileWatcher::addWatchFile(FileWatcher::FileDescription node)
{
lock.release();
this->listLocker.unlock();
// 文件删除再添加存在bugerrno=22
this->updateWatchFileType(node.url, node.type);
this->updateWatchFileAttribute(node.url, node.attr);
}