Handle empty Add-on backup properly (#3253)

* Handle empty Add-on backup properly

Check if the data directory exist in the backup. If not, make sure a
directory gets created so the options.json can be written afterwards.

* Remove unrelated change
This commit is contained in:
Stefan Agner 2021-10-22 10:48:53 +02:00 committed by GitHub
parent d2b706df05
commit f07193dc3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -859,7 +859,11 @@ class Addon(AddonModel):
# Restore data # Restore data
def _restore_data(): def _restore_data():
"""Restore data.""" """Restore data."""
shutil.copytree(Path(temp, "data"), self.path_data, symlinks=True) temp_data = Path(temp, "data")
if temp_data.is_dir():
shutil.copytree(temp_data, self.path_data, symlinks=True)
else:
self.path_data.mkdir()
_LOGGER.info("Restoring data for addon %s", self.slug) _LOGGER.info("Restoring data for addon %s", self.slug)
if self.path_data.is_dir(): if self.path_data.is_dir():