@xen-orchestra/backups 0.69.3 → 0.69.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -310,6 +310,7 @@ export const AbstractXapi = class AbstractXapiVmBackupRunner extends Abstract {
310
310
  // if not => remove it from the list to ensure we won't half destroy VM later
311
311
  vm.$VBDs
312
312
  .filter(({ $VDI }) => !!$VDI) // filter missing keys
313
+ .filter(({ $VDI }) => $VDI.$snapshot_of !== undefined) // skip non-snapshot VDIs (e.g., ISOs/CD-ROMs)
313
314
  .filter(({ $VDI }) => $VDI && vdiCandidates[$VDI.uuid] === undefined)
314
315
  .forEach(({ $VDI: outOfSnapshotsVdi, ...other }) => {
315
316
  warn(
@@ -16,6 +16,7 @@ import { DISK_TYPES } from 'vhd-lib/_constants.js'
16
16
  import { isVhdAlias, resolveVhdAlias } from 'vhd-lib/aliases.js'
17
17
  import { stringify } from 'uuid'
18
18
  import { dirname, join } from 'node:path'
19
+ import { RemoteVhdDiskChain } from './RemoteVhdDiskChain.mjs'
19
20
 
20
21
  export class RemoteVhdDisk extends RemoteDisk {
21
22
  /**
@@ -255,7 +256,11 @@ export class RemoteVhdDisk extends RemoteDisk {
255
256
  * @returns {Promise<number>} blockSize
256
257
  */
257
258
  async mergeBlock(childDisk, index, isResumingMerge) {
258
- if ((await this.isDirectory()) && childDisk instanceof RemoteVhdDisk && (await childDisk.isDirectory())) {
259
+ if (
260
+ (childDisk instanceof RemoteVhdDisk || childDisk instanceof RemoteVhdDiskChain) &&
261
+ (await this.isDirectory()) &&
262
+ (await childDisk.isDirectory())
263
+ ) {
259
264
  try {
260
265
  await this.#handler.rename(childDisk.getBlockPath(index), this.getBlockPath(index))
261
266
 
@@ -134,12 +134,7 @@ export class RemoteVhdDiskChain extends RemoteDisk {
134
134
  * @returns {Promise<boolean>} canMergeConcurently
135
135
  */
136
136
  async canMergeConcurently() {
137
- for (const disk of this.#disks) {
138
- if (!(await disk.isDirectory())) {
139
- return true
140
- }
141
- }
142
- return false
137
+ return this.isDirectory()
143
138
  }
144
139
 
145
140
  /**
@@ -221,6 +216,21 @@ export class RemoteVhdDiskChain extends RemoteDisk {
221
216
  throw new Error(`Can't merge block into a disk chain`)
222
217
  }
223
218
 
219
+ /**
220
+ * Gets a specific block path from the VHD directory disk.
221
+ * @param {number} index
222
+ * @returns {string} blockPath
223
+ */
224
+ getBlockPath(index) {
225
+ for (const disk of [...this.#disks].reverse()) {
226
+ if (disk.hasBlock(index)) {
227
+ return disk.getBlockPath(index)
228
+ }
229
+ }
230
+
231
+ throw new Error(`Block ${index} not found in chain`)
232
+ }
233
+
224
234
  /**
225
235
  * @returns {VhdFooter}
226
236
  */
@@ -269,4 +279,17 @@ export class RemoteVhdDiskChain extends RemoteDisk {
269
279
  await disk.unlink()
270
280
  }
271
281
  }
282
+
283
+ /**
284
+ * Check if all the disks in the chain are VHD directories.
285
+ * @returns {Promise<boolean>}
286
+ */
287
+ async isDirectory() {
288
+ for (const disk of this.#disks) {
289
+ if (!(await disk.isDirectory())) {
290
+ return false
291
+ }
292
+ }
293
+ return true
294
+ }
272
295
  }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/vatesfr/xen-orchestra.git"
10
10
  },
11
- "version": "0.69.3",
11
+ "version": "0.69.5",
12
12
  "engines": {
13
13
  "node": ">=14.18"
14
14
  },