From 322e8d95ee69e45055a713ba2f5619ca2e2a77ab Mon Sep 17 00:00:00 2001 From: JunjieBai Date: Thu, 18 May 2023 09:50:48 +0800 Subject: [PATCH] Increase the filtering of the unauthorized folders while add search dirs. --- search-ukcc-plugin/search.cpp | 8 ++ search-ukcc-plugin/search.h | 3 +- search-ukcc-plugin/translations/bo_CN.ts | 98 ++++++++++--------- search-ukcc-plugin/translations/en_US.ts | 114 ++++++++++++----------- search-ukcc-plugin/translations/zh_CN.ts | 98 ++++++++++--------- 5 files changed, 174 insertions(+), 147 deletions(-) diff --git a/search-ukcc-plugin/search.cpp b/search-ukcc-plugin/search.cpp index 348d113..c9e4bdb 100644 --- a/search-ukcc-plugin/search.cpp +++ b/search-ukcc-plugin/search.cpp @@ -506,6 +506,9 @@ void Search::initFileDialog() case ReturnCode::Hidden : QMessageBox::warning(m_pluginWidget, tr("Warning"), tr("Add search folder failed, hidden path is not supported!")); break; + case ReturnCode::PermissionDenied: + QMessageBox::warning(m_pluginWidget, tr("Warning"), tr("Add search folder failed, permission denied!")); + break; default: break; } @@ -615,6 +618,11 @@ void Search::initSearchDirs() int Search::setSearchDir(const QString &dirPath, const bool isAdd) { + QFileInfo info(dirPath); + if (!(info.isExecutable() && info.isReadable())) { + return ReturnCode::PermissionDenied; + } + if (!m_setSearchDirInterface->isValid()) { return ReturnCode::DirWatcherError; } diff --git a/search-ukcc-plugin/search.h b/search-ukcc-plugin/search.h index aa1c0e9..56e9d5c 100644 --- a/search-ukcc-plugin/search.h +++ b/search-ukcc-plugin/search.h @@ -63,7 +63,8 @@ enum ReturnCode { RepeatMount2, NotExists, HasBeenBlocked, - Hidden + Hidden, + PermissionDenied }; class Search : public QObject, CommonInterface diff --git a/search-ukcc-plugin/translations/bo_CN.ts b/search-ukcc-plugin/translations/bo_CN.ts index 7220b0b..2cb087b 100644 --- a/search-ukcc-plugin/translations/bo_CN.ts +++ b/search-ukcc-plugin/translations/bo_CN.ts @@ -5,51 +5,51 @@ Search - + Search འཚོལ་ཞིབ། /Search/Search - + Create index གསར་འཛུགས་འཚོལ་ཞིབ་བྱེད་པར་ཁྲིད་སྟོན། /Search/Create index - + Creating index can help you getting results quickly. སྟོན་གྲངས་གསར་སྐྲུན་བྱས་ན་ཁྱོད་ལ་མགྱོགས་མྱུར་ངང་གྲུབ་འབྲས་ཐོབ་པར་རོགས་རམ་བྱེད་ཐུབ། - + Default web searching engine ཁོག་གི་དྲ་ཤོག་གཏོད་པ་བཤེར་འཚོལ་རིགས་དབྱིབས། /Search/Default web searching engine - + baidu པའེ་ཏུའུ། - + sougou སོའོ་གོའུ། - + 360 360 - + Block Folders ལྐོག་བཀོད་མིང་ཐོ། /Search/Block Folders - + Following folders will not be searched. You can set it by adding and removing folders. གཤམ་གྱི་ཡིག་སྣོད་འཚོལ་བཤེར་མི་བྱེད། ཡིག་སྣོད་གསར་སྣོན་དང་གསུབ་འཕྲི་བྱས་ཚེ་ཡིག་ཆའི་དཀར་ཆག་སྒྲིག་འགོད་བྱ་ཐུབ། @@ -58,94 +58,95 @@ བསལ་འདེམས་ཀྱི་དཀར་ཆག། - - + + delete བསུབ་པ། - - + + Directories དཀར་ཆག - + File Content Search /Search/File Content Search - + show more results that match the keyword - + Fuzzy Search - + Precise Search - + show the results that exactly match the keyword - + Search Folders /Search/Search Folders - + Following folders will be searched. You can set it by adding and removing folders. - + select blocked folder བཀག་སྡོམ་བྱས་པའི་ཡིག་སྣོད་གདམ་གསེས - - + + Select བདམས་ཐོན་བྱུང་བ། - - + + Position: གོ་གནས་ནི། - - + + FileName: ཡིག་ཆའི་མིང་ནི། - - + + FileType: ཡིག་ཆའི་རིགས་དབྱིབས་ནི། - - + + Cancel ཕྱིར་འཐེན། - - - - + + + + + @@ -156,11 +157,16 @@ ཐ་ཚིག་སྒྲོག་པ། - - + + Add search folder failed, hidden path is not supported! + + + Add search folder failed, permission denied! + + Add blocked folder failed, choosen path is empty! སྦྱོར་རྟ་ལྐོག་བཀོད་མིང་ཐོ་ཕམ་ཁ་བསལ་འདེམས་ཀྱི་ཐབས་ལམ་སྟོང་བ་རེད། @@ -170,47 +176,47 @@ སྦྱོར་རྟ་ལྐོག་བཀོད་མིང་ཐོ་ཕམ་ཁ་བསལ་འདེམས་ཀྱི་དཀར་ཆག་མི་ཁྱིམ་དཀར་ཆག་འོག། - + Add blocked folder failed, its parent dir has been added! སྦྱོར་རྟ་ལྐོག་བཀོད་མིང་ཐོ་ཕམ་ཁ་བསལ་འདེམས་ཀྱི་དཀར་ཆག་ནི་ལྐོག་བཀོད་མིང་ཐོ་འི་ཁྲོད་ཀྱི་དཀར་ཆག་འོག - + Add blocked folder failed, choosen path is not exist! - + Add blocked folder failed, it has already been blocked! སྦྱོར་རྟ་ལྐོག་བཀོད་མིང་ཐོ་ཕམ་ཁ་བསལ་འདེམས་ཀྱི་དཀར་ཆག་ནི་ལྐོག་བཀོད་མིང་ཐོ་འི་ཁྲོད་ཀྱི་དཀར་ཆག་འོག - + select search folder - + Add search folder failed, choosen path is not supported currently! - + Add search folder failed, another path which is in the same device has been added! - + Add search folder failed, choosen path or its parent dir has been added! - + Add search folder failed, choosen path is in repeat mounted devices and another path which is in the same device has been added! - + Add search folder failed, choosen path is not exists! diff --git a/search-ukcc-plugin/translations/en_US.ts b/search-ukcc-plugin/translations/en_US.ts index 70a61ff..c70c74c 100644 --- a/search-ukcc-plugin/translations/en_US.ts +++ b/search-ukcc-plugin/translations/en_US.ts @@ -5,137 +5,138 @@ Search - + Search Search /Search/Search - + Default web searching engine Default web searching engine /Search/Default web searching engine - + baidu - + sougou - + 360 - + Create index Create index /Search/Create index - + Creating index can help you getting results quickly. - + File Content Search File Content Search /Search/File Content Search - + Precise Search - + show the results that exactly match the keyword - + Fuzzy Search - + show more results that match the keyword - + Search Folders Search Folders /Search/Search Folders - + Following folders will be searched. You can set it by adding and removing folders. - + Block Folders Block Folders /Search/Block Folders - + Following folders will not be searched. You can set it by adding and removing folders. + + + + Directories + + + + + select blocked folder + + + + + + Select + + - Directories + Position: - select blocked folder + + FileName: - Select + FileType: - Position: - - - - - - FileName: - - - - - - FileType: - - - - - Cancel - - - - + + + + + @@ -146,59 +147,64 @@ - + Add blocked folder failed, its parent dir has been added! - + Add blocked folder failed, choosen path is not exist! - + Add blocked folder failed, it has already been blocked! - + select search folder - + Add search folder failed, choosen path or its parent dir has been added! - + Add search folder failed, choosen path is not supported currently! - + Add search folder failed, choosen path is in repeat mounted devices and another path which is in the same device has been added! - + Add search folder failed, another path which is in the same device has been added! - + Add search folder failed, choosen path is not exists! - - + + Add search folder failed, hidden path is not supported! - - + + Add search folder failed, permission denied! + + + + + delete diff --git a/search-ukcc-plugin/translations/zh_CN.ts b/search-ukcc-plugin/translations/zh_CN.ts index cf480f2..558a8e0 100644 --- a/search-ukcc-plugin/translations/zh_CN.ts +++ b/search-ukcc-plugin/translations/zh_CN.ts @@ -5,51 +5,51 @@ Search - + Search 全局搜索 /Search/Search - + Create index 创建索引 /Search/Create index - + Creating index can help you getting results quickly. 开启之后可以快速获取搜索结果 - + Default web searching engine 默认互联网搜索引擎 /Search/Default web searching engine - + baidu 百度 - + sougou 搜狗 - + 360 360 - + Block Folders 排除的文件夹 /Search/Block Folders - + Following folders will not be searched. You can set it by adding and removing folders. 搜索将不查看以下文件夹,通过添加和删除可以设置排除的文件夹位置 @@ -58,94 +58,95 @@ 添加 - - + + delete 删除 - - + + Directories 文件夹 - + File Content Search 搜索文本内容 /Search/File Content Search - + show more results that match the keyword 显示更多与输入内容匹配的搜索结果 - + Fuzzy Search 模糊搜索 - + Precise Search 精确搜索 - + show the results that exactly match the keyword 仅显示与输入内容完全一致的搜索结果 - + Search Folders 搜索范围 /Search/Search Folders - + Following folders will be searched. You can set it by adding and removing folders. 以下文件的内容将出现在全局搜索的结果中 - + select blocked folder 选择排除的文件夹 - - + + Select 选择 - - + + Position: 位置 - - + + FileName: 文件名 - - + + FileType: 类型 - - + + Cancel 取消 - - - - + + + + + @@ -156,53 +157,58 @@ 警告 - - + + Add search folder failed, hidden path is not supported! 添加失败,不支持隐藏目录! - + + Add search folder failed, permission denied! + 添加失败,该目录无权限访问! + + + Add blocked folder failed, its parent dir has been added! 添加失败,父目录已被添加! - + Add blocked folder failed, choosen path is not exist! 添加失败,要添加的路径不存在! - + Add blocked folder failed, it has already been blocked! 添加失败,这个文件夹已经被添加过了! - + select search folder 选择要搜索的文件夹 - + Add search folder failed, choosen path is not supported currently! 添加失败!暂不支持该目录! - + Add search folder failed, another path which is in the same device has been added! 添加失败!文件夹位于重复挂载设备下,相同内容的文件夹已被添加! - + Add search folder failed, choosen path or its parent dir has been added! 添加失败!该目录或其父目录已被添加! - + Add search folder failed, choosen path is in repeat mounted devices and another path which is in the same device has been added! 添加失败!文件夹位于重复挂载设备下,且该设备另一个挂载点的文件夹已被添加! - + Add search folder failed, choosen path is not exists! 添加失败!要添加的路径不存在!