Fixed crash on enumerate + rvalue

This commit is contained in:
catalinvasile
2024-07-11 17:57:31 +02:00
parent 28b74b4056
commit 5ec1fddf57
10 changed files with 30 additions and 34 deletions
+6 -9
View File
@@ -499,7 +499,7 @@ GetStatResult CustomFilesystem::getStat(AbsPathView path) const
//////////////////////////////////////////////////////////////////////////
cppcoro::generator<EnumerateEntry> CustomFilesystem::enumerate(AbsPathView path) const
cppcoro::generator<EnumerateEntry> CustomFilesystem::enumerate(AbsPath path) const
{
AbsPath basePackPath;
for (const auto& pd : m_packsData)
@@ -521,19 +521,16 @@ cppcoro::generator<EnumerateEntry> CustomFilesystem::enumerate(AbsPathView path)
//////////////////////////////////////////////////////////////////////////
cppcoro::generator<EnumerateEntry> CustomFilesystem::enumerateRecursively(AbsPathView path) const
cppcoro::generator<EnumerateEntry> CustomFilesystem::enumerateRecursively(AbsPath path) const
{
tl::unordered_set<RelPath> checkedFiles;
const AbsPath rootPath(path);
//Note, the path might not survive after the first co_yield, if it came from a rvalue, in some conditions, so use the rootPath
AbsPath basePackPath;
for (const auto& pd : m_packsData)
{
if (pd.mountPoint.is_prefix_of(rootPath))
if (pd.mountPoint.is_prefix_of(path))
{
convertToPackPath(basePackPath, rootPath, pd.mountPoint);
convertToPackPath(basePackPath, path, pd.mountPoint);
if (!basePackPath.empty())
{
@@ -548,9 +545,9 @@ cppcoro::generator<EnumerateEntry> CustomFilesystem::enumerateRecursively(AbsPat
co_yield std::move(ee);
}
}
else if (rootPath.is_prefix_of(pd.mountPoint))
else if (path.is_prefix_of(pd.mountPoint))
{
const RelPathView parentPath = rootPath.path_to(pd.mountPoint);
const RelPathView parentPath = path.path_to(pd.mountPoint);
RelPath p = parentPath;
for (EnumerateEntry ee : pd.pack->enumerateRecursively(AbsPath(PosixRootTag::value())))