Try fix the macOS CI issue.

getNodeFromPath() now translates paths under the configured root—such as /var/...—to the canonical root—such as /private/var/..  before calling realpath(). This keeps moved/deleted paths resolvable after the original leaf disappears.
This commit is contained in:
Martín Lucas Golini
2026-08-17 23:34:46 -03:00
parent aebcc353c9
commit 1b2927e129
+15 -1
View File
@@ -392,6 +392,18 @@ void FileSystemModel::setRootPath( const std::string& rootPath ) {
FileSystemModel::Node* FileSystemModel::getNodeFromPath( std::string path, bool folderNode,
bool invalidateTree ) {
// A configured root can be an alias of its canonical path (for example, /var maps to
// /private/var on macOS). Translate that prefix first so a moved or deleted leaf, which can no
// longer be resolved by realpath(), still maps to the canonical paths stored by the model.
const bool rootMatches =
!mRootPath.empty() &&
( path == mRootPath ||
( String::startsWith( path, mRootPath ) &&
( mRootPath.back() == '/' || mRootPath.back() == '\\' ||
( path.size() > mRootPath.size() &&
( path[mRootPath.size()] == '/' || path[mRootPath.size()] == '\\' ) ) ) ) );
if ( mRootPath != mRealRootPath && rootMatches )
path.replace( 0, mRootPath.size(), mRealRootPath );
path = FileSystem::getRealPath( path );
if ( folderNode && !FileSystem::isDirectory( path ) )
path = FileSystem::fileRemoveFileName( path );
@@ -428,7 +440,9 @@ FileSystemModel::Node* FileSystemModel::getNodeFromPath( std::string path, bool
std::string_view FileSystemModel::getNodeRelativePath( const Node* node ) const {
auto rp = std::string_view{ node->fullPath() };
if ( mRootPath.size() < rp.size() )
if ( mRealRootPath.size() < rp.size() && String::startsWith( rp, mRealRootPath ) )
return rp.substr( mRealRootPath.size() );
if ( mRootPath.size() < rp.size() && String::startsWith( rp, mRootPath ) )
return rp.substr( mRootPath.size() );
return rp;
}