add date prefix to backup download name

This commit is contained in:
avollkopf 2024-05-10 21:29:53 +02:00
parent 2180cad285
commit 9d928cd58f
3 changed files with 12 additions and 5 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.4.1.a8"
__version__ = "4.4.1.a9"
__codename__ = "Yeast Starter"

View file

@ -15,7 +15,7 @@ import zipfile
import socket
import importlib
from tabulate import tabulate
from datetime import datetime, timedelta
from datetime import datetime, timedelta, date
try:
from systemd import journal
@ -48,9 +48,15 @@ class SystemController:
pass
async def backupConfig(self):
output_filename = "cbpi4_config"
try:
current_date = date.today()
current_date=str(current_date).replace("-","_")
output_filename = current_date+"_cbpi4_config"
except:
output_filename = "cbpi4_config"
dir_name = pathlib.Path(self.cbpi.config_folder.get_file_path(''))
shutil.make_archive(output_filename, 'zip', dir_name)
return output_filename+".zip"
async def plugins_list(self):
result = []

View file

@ -140,9 +140,10 @@ class SystemHttpEndpoints:
content: # Response body
application/zip: # Media type
"""
await self.controller.backupConfig()
filename = "cbpi4_config.zip"
filename = await self.controller.backupConfig()
#filename = "cbpi4_config.zip"
file_name = pathlib.Path(os.path.join(".", filename))
logging.error(file_name)
response = web.StreamResponse(
status=200,