ensure we have atleast 1GB before making an update

This commit is contained in:
Girish Ramakrishnan
2021-11-16 18:20:12 -08:00
parent b6ee1fb662
commit 6d864d3621
2 changed files with 6 additions and 8 deletions

View File

@@ -71,18 +71,14 @@ async function checkPreconditions(apiConfig, dataLayout, callback) {
for (let localPath of dataLayout.localPaths()) {
debug(`checkPreconditions: getting disk usage of ${localPath}`);
let result = safe.child_process.execSync(`du -Dsb ${localPath}`, { encoding: 'utf8' });
if (!result) return callback(new BoxError(BoxError.FS_ERROR, safe.error));
if (!result) return callback(new BoxError(BoxError.FS_ERROR, `du error: ${safe.error.message}`));
used += parseInt(result, 10);
}
debug(`checkPreconditions: ${used} bytes`);
let result;
try {
result = await df.file(getBackupPath(apiConfig));
} catch(error) {
return callback(new BoxError(BoxError.FS_ERROR, error));
}
const [error, result] = await safe(df.file(getBackupPath(apiConfig)));
if (error) return callback(new BoxError(BoxError.FS_ERROR, `Error when checking for disk space: ${error.message}`));
// Check filesystem is mounted so we don't write into the actual folder on disk
if (apiConfig.provider === PROVIDER_SSHFS || apiConfig.provider === PROVIDER_CIFS || apiConfig.provider === PROVIDER_NFS || apiConfig.provider === PROVIDER_EXT4) {