Fix saving of hardlinked files

Our atomic write involves writing a temp file and renaming that (which is
the only way to achieve something atomic). This creates a new inode, and
disconnects any hardlinks.

Note that the existing implementation for file paths with needsDevice
already keeps hardlinks intact, because even though it first writes into
a local temporary file it then writes the content directly into the
target with dd.

Check the number of hard links via system API and fallback to unsafe
writing if there are any, for desktop paths.

Fixes: QTCREATORBUG-19651
Change-Id: I3ce1ee81f339f241f0a2c9aa6f2259cb118ebef6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Eike Ziller
2023-03-28 16:45:16 +02:00
parent 59c1fae60b
commit 3ba769fb46
5 changed files with 45 additions and 5 deletions

View File

@@ -564,6 +564,11 @@ bool FilePath::isSymLink() const
return fileAccess()->isSymLink(*this);
}
bool FilePath::hasHardLinks() const
{
return fileAccess()->hasHardLinks(*this);
}
/*!
\brief Creates a directory in this location.