remove call to boost::filesystem::canonical when preparing indexer (issue #1149) (#1151)

boost::filesystem::canonical causes issues on Windows and will throw an exception if path is too long. Now those paths will be ignored by the indexer because boost::filesystem::exists returns false.
This commit is contained in:
Malte Langkabel
2021-02-25 07:38:01 +01:00
committed by GitHub
parent 5a2b0fd591
commit 7cb232af86
2 changed files with 10 additions and 10 deletions
+7 -8
View File
@@ -63,7 +63,7 @@ std::vector<FileInfo> FileSystem::getFileInfosFromPaths(
}
std::set<boost::filesystem::path> symlinkDirs;
std::set<boost::filesystem::path> filePaths;
std::set<FilePath> filePaths;
std::vector<FileInfo> files;
@@ -112,25 +112,24 @@ std::vector<FileInfo> FileSystem::getFileInfosFromPaths(
(ext.empty() ||
ext.find(utility::toLowerCase(it->path().extension().wstring())) != ext.end()))
{
boost::filesystem::path p = boost::filesystem::canonical(it->path());
if (filePaths.find(p) != filePaths.end())
const FilePath canonicalPath = FilePath(it->path().wstring()).getCanonical();
if (filePaths.find(canonicalPath) != filePaths.end())
{
continue;
}
filePaths.insert(p);
files.push_back(getFileInfoForPath(FilePath(it->path().wstring())));
filePaths.insert(canonicalPath);
files.push_back(getFileInfoForPath(canonicalPath));
}
}
}
else if (path.exists() && (ext.empty() || ext.find(utility::toLowerCase(path.extension())) != ext.end()))
{
const FilePath canonicalPath = path.getCanonical();
boost::filesystem::path p = canonicalPath.getPath();
if (filePaths.find(p) != filePaths.end())
if (filePaths.find(canonicalPath) != filePaths.end())
{
continue;
}
filePaths.insert(p);
filePaths.insert(canonicalPath);
files.push_back(getFileInfoForPath(canonicalPath));
}
}
+3 -2
View File
@@ -19,7 +19,7 @@ bool isInFileInfos(const std::vector<FileInfo>& infos, const std::wstring& filen
{
for (const FileInfo& info: infos)
{
if (info.path.wstr() == filename)
if (info.path.getAbsolute().wstr() == FilePath(filename).getCanonical().wstr())
{
return true;
}
@@ -33,7 +33,8 @@ bool isInFileInfos(
{
for (const FileInfo& info: infos)
{
if (info.path.wstr() == filename || info.path.wstr() == filename2)
if (info.path.wstr() == FilePath(filename).getCanonical().wstr() ||
info.path.wstr() == FilePath(filename2).getCanonical().wstr())
{
return true;
}