From 1b2927e129e466afa1afa833af1aa258ea138a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Mon, 17 Aug 2026 23:34:46 -0300 Subject: [PATCH] =?UTF-8?q?Try=20fix=20the=20macOS=20CI=20issue.=20getNode?= =?UTF-8?q?FromPath()=20now=20translates=20paths=20under=20the=20configure?= =?UTF-8?q?d=20root=E2=80=94such=20as=20/var/...=E2=80=94to=20the=20canoni?= =?UTF-8?q?cal=20root=E2=80=94such=20as=20/private/var/..=20=20before=20ca?= =?UTF-8?q?lling=20realpath().=20This=20keeps=20moved/deleted=20paths=20re?= =?UTF-8?q?solvable=20after=20the=20original=20leaf=20disappears.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/eepp/ui/models/filesystemmodel.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/eepp/ui/models/filesystemmodel.cpp b/src/eepp/ui/models/filesystemmodel.cpp index f98ab1a15..9a6bc5eef 100644 --- a/src/eepp/ui/models/filesystemmodel.cpp +++ b/src/eepp/ui/models/filesystemmodel.cpp @@ -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; }