[GRASS-SVN] r73692 - grass/trunk/lib/init

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 21 11:05:25 PST 2018


Author: mmetz
Date: 2018-11-21 11:05:25 -0800 (Wed, 21 Nov 2018)
New Revision: 73692

Modified:
   grass/trunk/lib/init/grass.py
Log:
lib/init: clean up sqlite db if existing, see #3697

Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py	2018-11-21 15:37:10 UTC (rev 73691)
+++ grass/trunk/lib/init/grass.py	2018-11-21 19:05:25 UTC (rev 73692)
@@ -2228,6 +2228,21 @@
 
         # close GUI if running
         close_gui()
+        # clean the sqlite db
+        from grass.script import db as gdb
+        from grass.script import core as gcore
+        conn = gdb.db_connection()
+        if conn and conn['driver'] == 'sqlite':
+	    # check if db exists
+	    gisenv = gcore.gisenv()
+	    database = conn['database']
+	    database = database.replace('$GISDBASE', gisenv['GISDBASE'])
+	    database = database.replace('$LOCATION_NAME', gisenv['LOCATION_NAME'])
+	    database = database.replace('$MAPSET', gisenv['MAPSET'])
+	    if os.path.exists(database):
+		message(_("Cleaning up sqlite database ..."))
+		gcore.start_command('db.execute', sql = 'VACUUM')
+
         # here we are at the end of grass session
         clear_screen()
         # save 'last used' GISRC after removing variables which shouldn't



More information about the grass-commit mailing list