better debugs

This commit is contained in:
Girish Ramakrishnan
2022-11-05 08:43:02 +01:00
parent aae52ec795
commit 8a5d4e2fb0
3 changed files with 7 additions and 7 deletions

View File

@@ -64,7 +64,7 @@ async function checkPreconditions(backupConfig, dataLayout) {
// check mount status before uploading
const status = await storage.api(backupConfig.provider).getBackupProviderStatus(backupConfig);
debug(`upload: mount point status is ${JSON.stringify(status)}`);
if (status.state !== 'active') throw new BoxError(BoxError.MOUNT_ERROR, `Backup endpoint is not mounted: ${status.message}`);
if (status.state !== 'active') throw new BoxError(BoxError.MOUNT_ERROR, `Backup endpoint is not active: ${status.message}`);
// check availabe size. this requires root for df to work
const df = await storage.api(backupConfig.provider).getAvailableSize(backupConfig);
@@ -76,7 +76,7 @@ async function checkPreconditions(backupConfig, dataLayout) {
used += parseInt(result, 10);
}
debug(`checkPreconditions: ${used} bytes`);
debug(`checkPreconditions: total required =${used} available=${df.available}`);
const needed = 0.6 * used + (1024 * 1024 * 1024); // check if there is atleast 1GB left afterwards. aim for 60% because rsync/tgz won't need full 100%
if (df.available <= needed) throw new BoxError(BoxError.FS_ERROR, `Not enough disk space for backup. Needed: ${prettyBytes(needed)} Available: ${prettyBytes(df.available)}`);