TUFLOW-Support / QGIS-TUFLOW-Plugin

TUFLOW related QGIS Plugins
9 stars 7 forks source link

Unexpected behaviour: "Move Source Layer to Superseded (SS) folder" #40

Open ZedeN1 opened 2 weeks ago

ZedeN1 commented 2 weeks ago

Issue:

When using GPKG files and ticking Move Source Layer to Superseded (SS) folder, the file does not move unless Increment layer and preserve database is checked.

When incrementing single layer GPKG file, one should not need to preserve database for the original file to be superseded.

The cause of this issue is: https://github.com/TUFLOW-Support/QGIS-TUFLOW-Plugin/blob/c1588e3f6226b6e0d739fec9107fd4de48c75b4c/tuflow/tuflowqgis_dialog.py#L601-L603

The if statement can be changed to check length of the Database layers:

if self.isgpkg and not incrementDatabase and len(incrementDatabaseLayers) > 1:
    pass 
else: 

Separate but related issue:

For consistency would be better to rename (SS) to (ss) in the UI. 'ss' is the actual folder created and the superseded files moved to.

https://github.com/TUFLOW-Support/QGIS-TUFLOW-Plugin/blob/c1588e3f6226b6e0d739fec9107fd4de48c75b4c/tuflow/forms/ui_tuflowqgis_increment.ui#L128

https://github.com/TUFLOW-Support/QGIS-TUFLOW-Plugin/blob/c1588e3f6226b6e0d739fec9107fd4de48c75b4c/tuflow/forms/ui_tuflowqgis_increment.py#L258

EllisSymons commented 1 week ago

Hi, yes you are completely right. I've implemented your suggestion.

I also was having issues with the file being locked when the file was trying to be moved to the ss folder (on Windows at least). This was happening for both GPKG and Shapfiles. I implemented a further change so that the move was connected to a timer that triggered after the QGIS interface was released just so that QGIS has the chance to release any locks. This worked for Shapefiles, but doesn't help too well with GPKG (it works sometimes). Even after the datasource is changed, the GPKG appears to stay locked even though the datasource is no longer in the map layer registry (i.e. I was unable to even move the file manually in file explorer until QGIS was closed). It could be something that the tuflow plugin is doing that is causing the lock, but it has never previously been an issue so I don't really know.

Anyway, let me know if you're happy with the changes i've made!

Commit: b1898d61649e6917e6ce2c0fd57c184f1bff43f7