diff --git a/bazarr/backup.py b/bazarr/backup.py index e812a50cd..81ccf68ab 100644 --- a/bazarr/backup.py +++ b/bazarr/backup.py @@ -39,6 +39,7 @@ def get_backup_files(fullpath=True): return [{ 'type': 'backup', 'filename': os.path.basename(x), + 'size': sizeof_fmt(os.path.getsize(x)), 'date': datetime.fromtimestamp(os.path.getmtime(x)).strftime("%b %d %Y") } for x in file_list] @@ -195,3 +196,11 @@ def delete_backup_file(filename): except OSError: logging.debug(f'Unable to delete backup file {backup_file_path}') return False + + +def sizeof_fmt(num, suffix="B"): + for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: + if abs(num) < 1000.0: + return f"{num:3.1f} {unit}{suffix}" + num /= 1000.0 + return f"{num:.1f} Y{suffix}" diff --git a/frontend/src/@types/system.d.ts b/frontend/src/@types/system.d.ts index 11cb09072..2c193cf33 100644 --- a/frontend/src/@types/system.d.ts +++ b/frontend/src/@types/system.d.ts @@ -23,6 +23,7 @@ declare namespace System { interface Backups { type: string; filename: string; + size: string; date: string; id: number; } diff --git a/frontend/src/pages/System/Backups/table.tsx b/frontend/src/pages/System/Backups/table.tsx index 035d0d50e..7aec9ba2d 100644 --- a/frontend/src/pages/System/Backups/table.tsx +++ b/frontend/src/pages/System/Backups/table.tsx @@ -24,6 +24,11 @@ const Table: FunctionComponent = ({ backups }) => { accessor: "filename", className: "text-nowrap", }, + { + Header: "Size", + accessor: "size", + className: "text-nowrap", + }, { Header: "Time", accessor: "date",