diff --git a/src/storage/filesystem.js b/src/storage/filesystem.js index 1aa967f01..e98fea4e5 100644 --- a/src/storage/filesystem.js +++ b/src/storage/filesystem.js @@ -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) { diff --git a/src/updater.js b/src/updater.js index 172d3142a..5a0e07e02 100644 --- a/src/updater.js +++ b/src/updater.js @@ -148,9 +148,11 @@ async function update(boxUpdateInfo, options, progressCallback) { progressCallback({ percent: 10, message: 'Backing up' }); await backuptask.fullBackup({ preserveSecs: 3*7*24*60*60 }, (progress) => progressCallback({ percent: 10+progress.percent*70/100, message: progress.message })); + + await checkFreeDiskSpace(1024*1024*1024); // check again in case backup is in same disk } - debug('updating box %s', boxUpdateInfo.sourceTarballUrl); + debug(`Updating box with ${boxUpdateInfo.sourceTarballUrl}`); progressCallback({ percent: 70, message: 'Installing update' });