diff --git a/supervisor/api/backups.py b/supervisor/api/backups.py index 1b1b8e38e61..6c826c32f18 100644 --- a/supervisor/api/backups.py +++ b/supervisor/api/backups.py @@ -460,10 +460,14 @@ async def download(self, request: web.Request): raise APIError(f"Backup {backup.slug} is not in location {location}") _LOGGER.info("Downloading backup %s", backup.slug) - response = web.FileResponse(backup.all_locations[location]) + filename = backup.all_locations[location] + response = web.FileResponse(filename) response.content_type = CONTENT_TYPE_TAR + + if filename == f"{backup.slug}.tar": + filename = f"{RE_SLUGIFY_NAME.sub('_', backup.name)}.tar" response.headers[CONTENT_DISPOSITION] = ( - f"attachment; filename={RE_SLUGIFY_NAME.sub('_', backup.name)}.tar" + f"attachment; filename={filename}" ) return response