apptask: asyncify
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user