backups: move mount status to separate route

This commit is contained in:
Girish Ramakrishnan
2023-04-30 17:21:18 +02:00
parent 898413bfd4
commit 883915c9d3
7 changed files with 42 additions and 9 deletions

View File

@@ -27,6 +27,7 @@ exports = module.exports = {
testProviderConfig,
remount,
getMountStatus,
BACKUP_IDENTIFIER_BOX: 'box',
BACKUP_IDENTIFIER_MAIL: 'mail',
@@ -50,6 +51,7 @@ const assert = require('assert'),
eventlog = require('./eventlog.js'),
hat = require('./hat.js'),
locker = require('./locker.js'),
mounts = require('./mounts.js'),
path = require('path'),
paths = require('./paths.js'),
safe = require('safetydance'),
@@ -361,3 +363,18 @@ async function remount(auditSource) {
await storage.api(backupConfig.provider).remount(backupConfig);
}
async function getMountStatus() {
const backupConfig = await settings.getBackupConfig();
let hostPath;
if (mounts.isManagedProvider(backupConfig.provider)) {
hostPath = paths.MANAGED_BACKUP_MOUNT_DIR;
} else if (backupConfig.provider === 'mountpoint') {
hostPath = backupConfig.mountPoint;
} else if (backupConfig.provider === 'filesystem') {
hostPath = backupConfig.backupFolder;
}
return await mounts.getStatus(backupConfig.provider, hostPath); // { state, message }
}