mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-26 17:47:20 +00:00
Added backup file size to API and table view.
This commit is contained in:
parent
33ff7948e8
commit
e4c666f82b
3 changed files with 15 additions and 0 deletions
|
@ -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}"
|
||||
|
|
1
frontend/src/@types/system.d.ts
vendored
1
frontend/src/@types/system.d.ts
vendored
|
@ -23,6 +23,7 @@ declare namespace System {
|
|||
interface Backups {
|
||||
type: string;
|
||||
filename: string;
|
||||
size: string;
|
||||
date: string;
|
||||
id: number;
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue