qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.03k stars 2.92k forks source link

Processing Model management issue #50703

Open roya0045 opened 1 year ago

roya0045 commented 1 year ago

What is the bug or the crash?

When removing a model that has been added to QGIS this deletes the original file leading to loss of data without warning.

The current behaviour of the model provide is to take the model as-is when initially added and reuse that model. This means that any changes to the model file itself won't be transfered to the added model, but as the model name already exist, it won't be replaced or updated when imported again.

To update the stored instance the user would delete the stored model and replace it but deleting the stored model also delete the file where the model came from, even if the content are now distinct.

This behaviour is quite baffling, removing the model should not delete the file and when a name conflict there should be a prompt asking to replace the model and not block the process entirely.

Steps to reproduce the issue

  1. Create a model
  2. Add model
  3. Change model
  4. Try to update the stored model by replacing it
  5. Use "Delete model" to remove the instance
  6. Model file has been deleted, but the model is still listed in the model...

Versions

Tested on 3.22.11, I doubt this has been improved since then.

Supported QGIS version

New profile

Additional context

No response

roya0045 commented 1 year ago

Data loss tag seems fiting for this issue.

roya0045 commented 1 year ago

The 'deletion' occurs in https://github.com/qgis/QGIS/blob/master/python/plugins/processing/modeler/DeleteModelAction.py

roya0045 commented 1 year ago

Changing the name of the linked model update its content, but it seems that if the orginal name remains, it won't update the model.

roya0045 commented 1 year ago

Not sure if bug after looking more in depth, seems to be intended to create duplicate of models upon importing and reloading the duplicate model from the model folder instead of loading the original. This mean that if you use the one in the model folder as the main one, it's going to be deleted when removing it.

I would assume it would be better to simply have a pointer to the stored models and iterate through those path at launch instead of copying everything in a dedicated folder in the system.

This would mean that removing a model from the list would just be removing a setting entry instead of deleting a copy of a model.

alexbruy commented 8 months ago

I'd say this is intended behaviour. When model is added to the toolbox a copy is created and that copy will be used/editied/deleted.