enricofer / autoSaver

auto save current project
3 stars 7 forks source link

qgz support ? #15

Closed ChameleonScales closed 2 years ago

ChameleonScales commented 3 years ago

Is there an intention to support the qgz format ? Since it has become the default format, I think it would prevent some confusion to many users. It took me a while to figure out that this was the reason why I couldn't open my backup.

As a note to whoever fears having lost work : Your .qgz.bak is not corrupted, you just have to rename the extension to .qgs instead of .qgz.

mikedufty commented 2 years ago

qgz support would be a really great feature. I guess it may be difficult to implement? A less ideal but useful alternative could be for the autosaver to automatically name the backup xxxx.qgs.bak instead of xxx.qgz.bak I think this would actually be 99% as good, especially if the qgd file is also renamed appropriately.

Then restoring would just be a matter of removing the .bak from the filenames regardless of whether your original file was qgz or qgs

ChameleonScales commented 2 years ago

That would be fine for me, although I hope the api allows for saving as qgz, in which case it should be a piece of cake.

mikedufty commented 2 years ago

Yeah, could be very simple if so. Code appears to use QgsProject.instance().write() to save the backup, and I can't see any documentation of how to change that to qgz. May need to use the zip utilities to zip it?

I think the only modification to save as qgs would be to line 395 of autosave.py currently it is bakFileName = origFileName + ".bak" I think changing it to bakFileName = origFileName[:-1] + "s.bak"

Will remove the last letter of the filename and replace with s.bak so .qgs files will become .qgs.bak and qgz will become .qgs.bak also.

I have not tested this, but it looks like an easy fix to me, though I have not investigated understand how the .qgd file is being generated currently. Looks like it might be working by accident as one seems to be generated outside the .qgz when autosaver is running.

enricofer commented 2 years ago

fixed. https://github.com/enricofer/autoSaver/commit/b52535eb4944414540d8da4ef69e40f62b10c3ef thanks for suggestions