Added backup file size to API and table view.

This commit is contained in:
morpheus65535 2022-02-27 20:19:56 -05:00
parent 33ff7948e8
commit e4c666f82b
3 changed files with 15 additions and 0 deletions

View File

@ -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}"

View File

@ -23,6 +23,7 @@ declare namespace System {
interface Backups {
type: string;
filename: string;
size: string;
date: string;
id: number;
}

View File

@ -24,6 +24,11 @@ const Table: FunctionComponent<Props> = ({ backups }) => {
accessor: "filename",
className: "text-nowrap",
},
{
Header: "Size",
accessor: "size",
className: "text-nowrap",
},
{
Header: "Time",
accessor: "date",