fix(xo-server/file restore): ignore non-regular files/dirs (#6305)
Fixes zammad#7648 This also ignore (broken and valid) symlinks.
This commit is contained in:
parent
667d0724c3
commit
4d40b56d85
@ -15,7 +15,7 @@ const { deduped } = require('@vates/disposable/deduped.js')
|
|||||||
const { decorateMethodsWith } = require('@vates/decorate-with')
|
const { decorateMethodsWith } = require('@vates/decorate-with')
|
||||||
const { compose } = require('@vates/compose')
|
const { compose } = require('@vates/compose')
|
||||||
const { execFile } = require('child_process')
|
const { execFile } = require('child_process')
|
||||||
const { readdir, stat } = require('fs-extra')
|
const { readdir, lstat } = require('fs-extra')
|
||||||
const { v4: uuidv4 } = require('uuid')
|
const { v4: uuidv4 } = require('uuid')
|
||||||
const { ZipFile } = require('yazl')
|
const { ZipFile } = require('yazl')
|
||||||
const zlib = require('zlib')
|
const zlib = require('zlib')
|
||||||
@ -47,13 +47,12 @@ const resolveSubpath = (root, path) => resolve(root, `.${resolve('/', path)}`)
|
|||||||
const RE_VHDI = /^vhdi(\d+)$/
|
const RE_VHDI = /^vhdi(\d+)$/
|
||||||
|
|
||||||
async function addDirectory(files, realPath, metadataPath) {
|
async function addDirectory(files, realPath, metadataPath) {
|
||||||
try {
|
const stats = await lstat(realPath)
|
||||||
const subFiles = await readdir(realPath)
|
if (stats.isDirectory()) {
|
||||||
await asyncMap(subFiles, file => addDirectory(files, realPath + '/' + file, metadataPath + '/' + file))
|
await asyncMap(await readdir(realPath), file =>
|
||||||
} catch (error) {
|
addDirectory(files, realPath + '/' + file, metadataPath + '/' + file)
|
||||||
if (error == null || error.code !== 'ENOTDIR') {
|
)
|
||||||
throw error
|
} else if (stats.isFile()) {
|
||||||
}
|
|
||||||
files.push({
|
files.push({
|
||||||
realPath,
|
realPath,
|
||||||
metadataPath,
|
metadataPath,
|
||||||
@ -383,8 +382,12 @@ class RemoteAdapter {
|
|||||||
const entriesMap = {}
|
const entriesMap = {}
|
||||||
await asyncMap(await readdir(path), async name => {
|
await asyncMap(await readdir(path), async name => {
|
||||||
try {
|
try {
|
||||||
const stats = await stat(`${path}/${name}`)
|
const stats = await lstat(`${path}/${name}`)
|
||||||
entriesMap[stats.isDirectory() ? `${name}/` : name] = {}
|
if (stats.isDirectory()) {
|
||||||
|
entriesMap[name + '/'] = {}
|
||||||
|
} else if (stats.isFile()) {
|
||||||
|
entriesMap[name] = {}
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error == null || error.code !== 'ENOENT') {
|
if (error == null || error.code !== 'ENOENT') {
|
||||||
throw error
|
throw error
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
- [VDI Import] Fix `this._getOrWaitObject is not a function`
|
- [VDI Import] Fix `this._getOrWaitObject is not a function`
|
||||||
- [VM] Attempting to delete a protected VM should display a modal with the error and the ability to bypass it (PR [#6290](https://github.com/vatesfr/xen-orchestra/pull/6290))
|
- [VM] Attempting to delete a protected VM should display a modal with the error and the ability to bypass it (PR [#6290](https://github.com/vatesfr/xen-orchestra/pull/6290))
|
||||||
- [OVA Import] Fix import stuck after first disk
|
- [OVA Import] Fix import stuck after first disk
|
||||||
|
- [File restore] Ignore symbolic links
|
||||||
|
|
||||||
### Packages to release
|
### Packages to release
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user