apptask: asyncify

This commit is contained in:
Girish Ramakrishnan
2021-09-16 13:59:03 -07:00
parent b5539120f1
commit 9a2ed4f2c8
9 changed files with 505 additions and 744 deletions

View File

@@ -237,19 +237,16 @@ function getSnapshotInfo(id) {
return info[id] || { };
}
function setSnapshotInfo(id, info, callback) {
async function setSnapshotInfo(id, info) {
assert.strictEqual(typeof id, 'string');
assert.strictEqual(typeof info, 'object');
assert.strictEqual(typeof callback, 'function');
const contents = safe.fs.readFileSync(paths.SNAPSHOT_INFO_FILE, 'utf8');
const data = safe.JSON.parse(contents) || { };
if (info) data[id] = info; else delete data[id];
if (!safe.fs.writeFileSync(paths.SNAPSHOT_INFO_FILE, JSON.stringify(data, null, 4), 'utf8')) {
return callback(new BoxError(BoxError.FS_ERROR, safe.error.message));
throw new BoxError(BoxError.FS_ERROR, safe.error.message);
}
callback();
}
async function startCleanupTask(auditSource) {