Skip to content

Commit 31a8f3f

Browse files
lsixnyalldawson
authored andcommitted
Ensure qgis.db is writable when copied from RO source
In some package managers (such as NIX[1], used in NixOS[2]), all the data is installed into a read-only file system. When QGis is first launched on those systems, it copies the template `qgis.db` from the share directory into the user private .local directory, but keeps its permissions unchanged: readonly. Any attempt from QGIS to update this file fails. This commit makes sure that the `qgis.db` file is user writable when it is copied from the installation directory. [1] https://nixos.org/nix/ [2] https://nixos.org/
1 parent 81330ec commit 31a8f3f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/core/qgsapplication.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,19 @@ bool QgsApplication::createDatabase( QString *errorMessage )
15361536
}
15371537
return false;
15381538
}
1539+
1540+
QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
1541+
if ( !( perms & QFile::WriteOwner ) )
1542+
{
1543+
if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
1544+
{
1545+
if ( errorMessage )
1546+
{
1547+
*errorMessage = tr( "Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
1548+
}
1549+
return false;
1550+
}
1551+
}
15391552
}
15401553
else
15411554
{

0 commit comments

Comments
 (0)