[FEATURE] - Adding fileSize in backup model in order to display it.

This commit is contained in:
charlesgauthereau
2026-01-02 15:32:36 +01:00
parent c471423775
commit 619c32f09d
7 changed files with 1951 additions and 2 deletions
+10
View File
@@ -15,4 +15,14 @@ export function isUUID(str: string) {
export function isImportedFilename(name: string): boolean {
return name.startsWith("imported_");
}
export function formatBytes(bytes: number | null, decimals = 2): string {
if (!bytes) return "N/A";
if (bytes === 0) return "0 Bytes";
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
}