Files
xen-orchestra/@xen-orchestra/backups/parseMetadataBackupId.mjs
Julien Fontanet 1005e295b2 chore(backups): convert to ESM
BREAKING CHANGE
2023-07-10 16:45:13 +02:00

24 lines
600 B
JavaScript

import { DIR_XO_CONFIG_BACKUPS, DIR_XO_POOL_METADATA_BACKUPS } from './RemoteAdapter.mjs'
export function parseMetadataBackupId(backupId) {
const [dir, ...rest] = backupId.split('/')
if (dir === DIR_XO_CONFIG_BACKUPS) {
const [scheduleId, timestamp] = rest
return {
type: 'xoConfig',
scheduleId,
timestamp,
}
} else if (dir === DIR_XO_POOL_METADATA_BACKUPS) {
const [scheduleId, poolUuid, timestamp] = rest
return {
type: 'pool',
poolUuid,
scheduleId,
timestamp,
}
}
throw new Error(`not supported backup dir (${dir})`)
}