On Windows the plugin will intermittently refuse to overwrite an existing layer of the same name if it's loaded in the main qgis window. This i s a known issue with the underlying OSGEO library. To attempt to mitigate this I've added the following to remove the existing layers and reload all layers :
for lyr in QgsProject.instance().mapLayers().values():
if lyr.name()==name:
QgsProject.instance().removeMapLayers([lyr.id()])
QgsProject.instance().reloadAllLayers()
QgsProject.instance().reloadAllLayers()
This helps, but doesn't work every time for some reason. I can't replicate this fault under Linux.
EDIT
Should add that it doesn't care about the file existing already in the file system- only if it's loaded in QGIS
On Windows the plugin will intermittently refuse to overwrite an existing layer of the same name if it's loaded in the main qgis window. This i s a known issue with the underlying OSGEO library. To attempt to mitigate this I've added the following to remove the existing layers and reload all layers :
This helps, but doesn't work every time for some reason. I can't replicate this fault under Linux.
EDIT Should add that it doesn't care about the file existing already in the file system- only if it's loaded in QGIS