tudelft3d / 3DCityDB-Tools-for-QGIS

This repository contains code of a QGIS plugin that facilitates data handling of the CityGML 3D City Database.
Apache License 2.0
55 stars 2 forks source link

Uninstall error and unintended consequences #50

Closed pancost closed 11 months ago

pancost commented 11 months ago

ERROR: local variable 'usr_name' referenced before assignment

How did i notice it? I had an old server side version which I wanted (as prompted) to uninstall in order to install the newer supported one.

How to recreate it: 1) Go to QGIS Package Administrator 2) Connect to a database that DOES NOT have the main installation but has some data in it. 3) In Main installation click the install button. _2023-11-18T11:38:36 SUCCESS Schema 'qgis_pkg' installed 4) Add user to the group as normal. 2023-11-18T11:38:38 INFO User 'postgres' has been succesfully added to the database group 'qgis_pkg_usrgroup_citydb_vienna' 5) Create schema for said user as normal. 2023-11-18T11:38:40 SUCCESS Schema 'qgis_postgres' installed 6) Grand all privileges to user. 2023-11-18T11:38:44 INFO For user 'postgres', read & write privileges granted to ALL citydb schemas._ 7) Close the dialogue and open the "Layer Loader"

8) Follow the normal process to import any layer form the database. 2023-11-18T11:39:17 SUCCESS Layer(s) successfully imported 9) With the layer(s) loaded close the dialogue and go back to the QGIS Package Administrator. 10) Connect to the database where the loaded layers are coming from 11) In Main installation, click the "Uninstall from ..." button. _ 2023-11-18T11:39:31 CRITICAL Establishing temporary connection ERROR at 3DCityDB-Tools-for-QGIS/cdb4/gui_admin/functions/threads.py>uninstall_thread_qgis_pkg_current ERROR: local variable 'usr_name' referenced before assignment _

12) If you click it again, NO ERROR! _2023-11-18T11:40:07 SUCCESS Schema 'qgis_pkg' uninstalled_

However, now the connection to the loaded layer(s) is broken so an avalanche of errors from QGIS's PostGIS service is falling to the user. Even if we were to re-install the server-side with the exact same settings as before, the leftover layer(s) are going to remain broken and throwing errors.

So my proposal is that when users opt-out we clean their project from any connected layers. Although in cases where the user is decoupled from administrator (not the same person/computer) this might be impossible.

I think it is quite important to address it as updating from older server-side version by uninstalling them and installing the new ones is going to be a semi-frequent process for all users.

So first lets fix the ERROR because it persist even if you delete the loaded layers when attempting to uninstall.

PS. I had a deja vu about this error

gioagu commented 11 months ago

Closed in version 0.8.7