@xen-orchestra/backups 0.25.0 → 0.26.0

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/RemoteAdapter.js CHANGED
@@ -15,7 +15,7 @@ const { deduped } = require('@vates/disposable/deduped.js')
15
15
  const { decorateMethodsWith } = require('@vates/decorate-with')
16
16
  const { compose } = require('@vates/compose')
17
17
  const { execFile } = require('child_process')
18
- const { readdir, stat } = require('fs-extra')
18
+ const { readdir, lstat } = require('fs-extra')
19
19
  const { v4: uuidv4 } = require('uuid')
20
20
  const { ZipFile } = require('yazl')
21
21
  const zlib = require('zlib')
@@ -47,13 +47,12 @@ const resolveSubpath = (root, path) => resolve(root, `.${resolve('/', path)}`)
47
47
  const RE_VHDI = /^vhdi(\d+)$/
48
48
 
49
49
  async function addDirectory(files, realPath, metadataPath) {
50
- try {
51
- const subFiles = await readdir(realPath)
52
- await asyncMap(subFiles, file => addDirectory(files, realPath + '/' + file, metadataPath + '/' + file))
53
- } catch (error) {
54
- if (error == null || error.code !== 'ENOTDIR') {
55
- throw error
56
- }
50
+ const stats = await lstat(realPath)
51
+ if (stats.isDirectory()) {
52
+ await asyncMap(await readdir(realPath), file =>
53
+ addDirectory(files, realPath + '/' + file, metadataPath + '/' + file)
54
+ )
55
+ } else if (stats.isFile()) {
57
56
  files.push({
58
57
  realPath,
59
58
  metadataPath,
@@ -292,7 +291,7 @@ class RemoteAdapter {
292
291
  }
293
292
 
294
293
  #useVhdDirectory() {
295
- return this.handler.type === 's3'
294
+ return this.handler.useVhdDirectory()
296
295
  }
297
296
 
298
297
  #useAlias() {
@@ -383,8 +382,12 @@ class RemoteAdapter {
383
382
  const entriesMap = {}
384
383
  await asyncMap(await readdir(path), async name => {
385
384
  try {
386
- const stats = await stat(`${path}/${name}`)
387
- entriesMap[stats.isDirectory() ? `${name}/` : name] = {}
385
+ const stats = await lstat(`${path}/${name}`)
386
+ if (stats.isDirectory()) {
387
+ entriesMap[name + '/'] = {}
388
+ } else if (stats.isFile()) {
389
+ entriesMap[name] = {}
390
+ }
388
391
  } catch (error) {
389
392
  if (error == null || error.code !== 'ENOENT') {
390
393
  throw error
package/_cleanVm.js CHANGED
@@ -59,30 +59,20 @@ async function mergeVhdChain(chain, { handler, logInfo, remove, merge }) {
59
59
  let done, total
60
60
  const handle = setInterval(() => {
61
61
  if (done !== undefined) {
62
- logInfo(`merging children in progress`, { children, parent, doneCount: done, totalCount: total})
62
+ logInfo(`merging children in progress`, { children, parent, doneCount: done, totalCount: total })
63
63
  }
64
64
  }, 10e3)
65
65
 
66
66
  const mergedSize = await mergeVhd(handler, parent, handler, children, {
67
+ logInfo,
67
68
  onProgress({ done: d, total: t }) {
68
69
  done = d
69
70
  total = t
70
71
  },
72
+ remove,
71
73
  })
72
74
 
73
75
  clearInterval(handle)
74
- const mergeTargetChild = children.shift()
75
- await Promise.all([
76
- VhdAbstract.rename(handler, parent, mergeTargetChild),
77
- asyncMap(children, child => {
78
- logInfo(`the VHD child is already merged`, { child })
79
- if (remove) {
80
- logInfo(`deleting merged VHD child`, { child })
81
- return VhdAbstract.unlink(handler, child)
82
- }
83
- }),
84
- ])
85
-
86
76
  return mergedSize
87
77
  }
88
78
  }
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.25.0",
11
+ "version": "0.26.0",
12
12
  "engines": {
13
13
  "node": ">=14.6"
14
14
  },
@@ -46,7 +46,7 @@
46
46
  "tmp": "^0.2.1"
47
47
  },
48
48
  "peerDependencies": {
49
- "@xen-orchestra/xapi": "^1.1.0"
49
+ "@xen-orchestra/xapi": "^1.2.0"
50
50
  },
51
51
  "license": "AGPL-3.0-or-later",
52
52
  "author": {