diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index ed4a2667a59..5011d10ae81 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -20,6 +20,7 @@ > Users must be able to say: “I had this issue, happy to know it's fixed” - Fix SR tags not being listed in tag selectors (PR [#8251](https://github.com/vatesfr/xen-orchestra/pull/8251)) +- [Plugins/usage-report] Prevent the report creation from failing over and over when previous stats file is empty or incorrect (PR [#8240](https://github.com/vatesfr/xen-orchestra/pull/8240)) - [Backups/Logs] Display mirror backup transfer size (PR [#8224](https://github.com/vatesfr/xen-orchestra/pull/8224)) - [Settings/Remotes] Only allow using encryption when using data block storage to prevent errors during backups (PR [#8244](https://github.com/vatesfr/xen-orchestra/pull/8244)) @@ -43,6 +44,7 @@ - @xen-orchestra/web minor - @xen-orchestra/web-core minor - xo-server patch +- xo-server-usage-report patch - xo-web patch diff --git a/packages/xo-server-usage-report/src/index.js b/packages/xo-server-usage-report/src/index.js index e96720a6221..d8b3818c52c 100644 --- a/packages/xo-server-usage-report/src/index.js +++ b/packages/xo-server-usage-report/src/index.js @@ -546,7 +546,14 @@ async function storeStats({ data, storedStatsPath }) { async function computeEvolution({ storedStatsPath, ...newStats }) { try { - const oldStats = JSON.parse(await pReadFile(storedStatsPath, 'utf8')) + const fileContent = await pReadFile(storedStatsPath, 'utf8') + let oldStats + try { + oldStats = JSON.parse(fileContent) + } catch { + log.warn('Invalid or empty json stats file') + return + } const newStatsVms = newStats.vms const oldStatsVms = oldStats.global.vms const newStatsHosts = newStats.hosts