gramps-web-api
gramps-web-api copied to clipboard
Gramps XML export (and thus synchronization) can fail in case of corrupted objects
If some objects contain invalid data, such as None as handle, Gramps XML export can fail, which prevents backup as well as synchronization. We should have something like a "repair database" endpoint.
The best solution would of course be to just use the Gramps built-in check & repair tool, however that does not work since it also tries to check media checksums, which generally will not for in Web API because media files are managed differently.
~So the best solution for now in my opinion would be to create a new addon that is a ligher (or customizable) version of check.py, but not reimplementing any of the logic.~
On second though, I think an addon is overkill - we can just create a background task that runs the functions in the check and repair tool except media checksums.
Example traceback:
File "/usr/lib/python3/dist-packages/gramps/plugins/export/exportxml.py", line 179, in write
self.write_xml_data()
File "/usr/lib/python3/dist-packages/gramps/plugins/export/exportxml.py", line 313, in write_xml_data
self.write_source(source,2)
File "/usr/lib/python3/dist-packages/gramps/plugins/export/exportxml.py", line 616, in write_source
self.write_media_list(source.get_media_list(), index+1)
File "/usr/lib/python3/dist-packages/gramps/plugins/export/exportxml.py", line 1129, in write_media_list
self.g.write('%s<objref hlink="%s"' % (sp,"_"+mobj_id))
~~~^~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str
To be confirmed whether this is actually fixed.
Confirmed by the user that the issue is not fixed - media references with ref None still cause this error after running check & repair.