tooling: ensure intercepts do not overwrite symlinks to cfg files

Intercept-file writes could end up opening an existing vfs symlink
back to the user's actual config instead of creating a new file in the
vfs.
This commit is contained in:
outfoxxed 2026-04-02 03:21:25 -07:00
parent d612227740
commit 92b336c80c
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E

View file

@ -177,6 +177,8 @@ void QmlToolingSupport::updateToolingFs(
auto fileInfo = QFileInfo(path);
if (!fileInfo.isFile()) continue;
if (scanner.fileIntercepts.contains(path)) continue;
auto spath = linkDir.filePath(name);
auto sFileInfo = QFileInfo(spath);
@ -205,8 +207,10 @@ void QmlToolingSupport::updateToolingFs(
}
auto spath = linkDir.filePath(name);
QFile::remove(spath);
auto file = QFile(spath);
if (!file.open(QFile::ReadWrite | QFile::Text)) {
if (!file.open(QFile::ReadWrite | QFile::Text | QFile::NewOnly)) {
qCCritical(logTooling) << "Failed to open injected file" << spath;
continue;
}