Minor fixes.

This commit is contained in:
Julien Fontanet
2015-09-11 12:31:53 +02:00
parent 5f33aa7fd4
commit 012e5c09ed
2 changed files with 12 additions and 4 deletions

View File

@@ -495,16 +495,17 @@ exports.rollingSnapshot = rollingSnapshot
#---------------------------------------------------------------------
backup = $coroutine ({vm, pathToFile, compress, onlyMetadata}) ->
yield @backupVm({vm, pathToFile, compress: compress ? true, onlyMetadata: onlyMetadata ? false})
yield @backupVm({vm, pathToFile, compress, onlyMetadata})
backup.params = {
id: { type: 'string' }
pathToFile: { type: 'string' }
compress: { type: 'boolean', optional: true }
onlyMetadata: { type: 'boolean', optional: true }
}
backup.resolve = {
vm: ['id', 'VM', 'adminsistrate']
vm: ['id', 'VM', 'administrate']
}
backup.description = 'Exports a VM to the file system'
@@ -517,7 +518,14 @@ rollingBackup = $coroutine ({vm, remoteId, tag, depth, compress, onlyMetadata})
remote = yield @getRemote remoteId
if not remote?.path?
throw new Error "No such Remote #{remoteId}"
return yield @rollingBackupVm({vm, path: remote.path, tag, depth, compress: compress ? true})
return yield @rollingBackupVm({
vm,
path: remote.path,
tag,
depth,
compress,
onlyMetadata
})
rollingBackup.params = {
id: { type: 'string' }

View File

@@ -654,7 +654,7 @@ export default class Xo extends EventEmitter {
// -----------------------------------------------------------------
async backupVm ({vm, pathToFile, compress, onlyMetadata}) {
const targetStream = fs.createWriteStream(pathToFile, {flag: 'xw'})
const targetStream = fs.createWriteStream(pathToFile, { flags: 'wx' })
const sourceStream = await this.getXAPI(vm).exportVm(vm.id, {
compress,
onlyMetadata: onlyMetadata || false