@xen-orchestra/backups 0.16.1 → 0.16.2

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.
package/_cleanVm.js CHANGED
@@ -256,9 +256,12 @@ exports.cleanVm = async function cleanVm(
256
256
  const { vhds } = metadata
257
257
  return Object.keys(vhds).map(key => resolve('/', vmDir, vhds[key]))
258
258
  })()
259
+
260
+ const missingVhds = linkedVhds.filter(_ => !vhds.has(_))
261
+
259
262
  // FIXME: find better approach by keeping as much of the backup as
260
263
  // possible (existing disks) even if one disk is missing
261
- if (linkedVhds.every(_ => vhds.has(_))) {
264
+ if (missingVhds.length === 0) {
262
265
  linkedVhds.forEach(_ => unusedVhds.delete(_))
263
266
 
264
267
  // checking the size of a vhd directory is costly
@@ -277,7 +280,7 @@ exports.cleanVm = async function cleanVm(
277
280
  }
278
281
  }
279
282
  } else {
280
- onLog(`Some VHDs linked to the metadata ${json} are missing`)
283
+ onLog(`Some VHDs linked to the metadata ${json} are missing`, { missingVhds })
281
284
  if (remove) {
282
285
  onLog(`deleting incomplete backup ${json}`)
283
286
  await handler.unlink(json)
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.16.1",
11
+ "version": "0.16.2",
12
12
  "engines": {
13
13
  "node": ">=14.6"
14
14
  },
@@ -20,7 +20,7 @@
20
20
  "@vates/disposable": "^0.1.1",
21
21
  "@vates/parse-duration": "^0.1.1",
22
22
  "@xen-orchestra/async-map": "^0.1.2",
23
- "@xen-orchestra/fs": "^0.19.1",
23
+ "@xen-orchestra/fs": "^0.19.2",
24
24
  "@xen-orchestra/log": "^0.3.0",
25
25
  "@xen-orchestra/template": "^0.1.0",
26
26
  "compare-versions": "^4.0.1",
@@ -36,7 +36,7 @@
36
36
  "proper-lockfile": "^4.1.2",
37
37
  "pump": "^3.0.0",
38
38
  "uuid": "^8.3.2",
39
- "vhd-lib": "^2.0.2",
39
+ "vhd-lib": "^2.0.3",
40
40
  "yazl": "^2.5.1"
41
41
  },
42
42
  "peerDependencies": {
@@ -21,10 +21,18 @@ exports.MixinBackupWriter = (BaseClass = Object) =>
21
21
  this.#vmBackupDir = getVmBackupDir(this._backup.vm.uuid)
22
22
  }
23
23
 
24
- _cleanVm(options) {
25
- return this._adapter
26
- .cleanVm(this.#vmBackupDir, { ...options, fixMetadata: true, onLog: warn, lock: false })
27
- .catch(warn)
24
+ async _cleanVm(options) {
25
+ try {
26
+ return await this._adapter.cleanVm(this.#vmBackupDir, {
27
+ ...options,
28
+ fixMetadata: true,
29
+ onLog: warn,
30
+ lock: false,
31
+ })
32
+ } catch (error) {
33
+ warn(error)
34
+ return {}
35
+ }
28
36
  }
29
37
 
30
38
  async beforeBackup() {
@@ -43,7 +51,13 @@ exports.MixinBackupWriter = (BaseClass = Object) =>
43
51
  // merge worker only compatible with local remotes
44
52
  const { handler } = this._adapter
45
53
  if (merge && !disableMergeWorker && typeof handler._getRealPath === 'function') {
46
- await handler.outputFile(join(MergeWorker.CLEAN_VM_QUEUE, formatFilenameDate(new Date())), this._backup.vm.uuid)
54
+ const taskFile =
55
+ join(MergeWorker.CLEAN_VM_QUEUE, formatFilenameDate(new Date())) +
56
+ '-' +
57
+ // add a random suffix to avoid collision in case multiple tasks are created at the same second
58
+ Math.random().toString(36).slice(2)
59
+
60
+ await handler.outputFile(taskFile, this._backup.vm.uuid)
47
61
  const remotePath = handler._getRealPath()
48
62
  await MergeWorker.run(remotePath)
49
63
  }