Fix Backup info size display (#7540)

This commit is contained in:
Andrey Sobolev
2024-12-24 20:16:45 +07:00
committed by GitHub
parent b9cb463bfc
commit 30edf4ea8e
7 changed files with 38 additions and 12 deletions
+14 -7
View File
@@ -897,6 +897,12 @@ export async function backup (
while (true) {
try {
const currentChunk = await ctx.with('loadChunk', {}, () => connection.loadChunk(domain, idx))
if (domain === DOMAIN_BLOB) {
result.blobsSize += currentChunk.size ?? 0
} else {
result.dataSize += currentChunk.size ?? 0
}
idx = currentChunk.idx
ops++
@@ -1152,12 +1158,6 @@ export async function backup (
break
}
if (domain === DOMAIN_BLOB) {
result.blobsSize += (d as Blob).size
} else {
result.dataSize += JSON.stringify(d).length
}
function processChanges (d: Doc, error: boolean = false): void {
processed++
// Move processed document to processedChanges
@@ -1777,6 +1777,7 @@ export async function restore (
let loaded = 0
let el = 0
let chunks = 0
let dataSize = 0
try {
while (true) {
if (opt.progress !== undefined) {
@@ -1784,6 +1785,7 @@ export async function restore (
}
const st = Date.now()
const it = await connection.loadChunk(c, idx)
dataSize += it.size ?? 0
chunks++
idx = it.idx
@@ -1808,7 +1810,12 @@ export async function restore (
await connection.closeChunk(idx)
}
}
ctx.info('loaded', { loaded, workspace: workspaceId.name })
ctx.info('loaded', {
domain: c,
loaded,
workspace: workspaceId.name,
dataSize: Math.round((dataSize / (1024 * 1024)) * 100) / 100
})
ctx.info('\tcompare documents', {
size: changeset.size,
serverSize: serverChangeset.size,