Skip to content

Commit

Permalink
remove getTotalBackupsize of remoteInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuRA committed Sep 23, 2024
1 parent d082f79 commit a394810
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
7 changes: 0 additions & 7 deletions packages/xo-server/src/xo-mixins/remotes.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncMapSettled from '@xen-orchestra/async-map/legacy.js'
import Disposable from 'promise-toolbox/Disposable'
import Obfuscate from '@vates/obfuscate'
import { basename } from 'path'
import { createLogger } from '@xen-orchestra/log'
Expand All @@ -10,7 +9,6 @@ import { invalidParameters, noSuchObject } from 'xo-common/api-errors.js'
import { synchronized } from 'decorator-synchronized'

import patch from '../patch.mjs'
import { noop } from '../utils.mjs'
import { Remotes } from '../models/remote.mjs'

// ===================================================================
Expand Down Expand Up @@ -174,16 +172,11 @@ export default class {
})
: this.getRemoteHandler(remote.id).then(handler => handler.getInfo())

const totalBackupSize = await Disposable.use(this._app.getBackupsRemoteAdapter(remote), adapter =>
adapter.getTotalBackupSize()
).catch(noop)

try {
await timeout.call(
promise.then(info => {
remotesInfo[remote.id] = {
...info,
totalBackupSize,
encryption,
}
}),
Expand Down
10 changes: 7 additions & 3 deletions packages/xo-server/src/xo-mixins/rest-api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { pipeline } from 'node:stream/promises'
import { json, Router } from 'express'
import { Readable } from 'node:stream'
import cloneDeep from 'lodash/cloneDeep.js'
import Disposable from 'promise-toolbox/Disposable'
import groupBy from 'lodash/groupBy.js'
import path from 'node:path'
import pDefer from 'promise-toolbox/defer'
Expand Down Expand Up @@ -240,15 +241,18 @@ async function _getDashboardStats(app) {
continue
}

const { available, size, totalBackupSize, used } = backupRepositoryInfo
const totalBackupSize = await Disposable.use(app.getBackupsRemoteAdapter(backupRepository), adapter =>
adapter.getTotalBackupSize()
)
const { available, size, used } = backupRepositoryInfo

const isS3 = type === 's3'
const target = isS3 ? s3Brsize : otherBrSize

target.backups += totalBackupSize?.onDisk ?? 0
target.backups += totalBackupSize.onDisk
if (!isS3) {
target.available += available
target.other += used - (totalBackupSize?.onDisk ?? 0)
target.other += used - totalBackupSize.onDisk
target.total += size
target.used += used
}
Expand Down

0 comments on commit a394810

Please sign in to comment.