Handle empty Add-on backup properly
* 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
@@ -859,7 +859,11 @@ class Addon(AddonModel):
# Restore data
def _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)
if self.path_data.is_dir():
