_.each(folders, function(folder) { FoldersContentLibrary.purge(folder, function() { purgeCounter.decr(); }); purgeCounter.incr(); });
FoldersAPI.on(FoldersConstants.events.DELETED_FOLDER, function(ctx, folder, memberIds) { // Keep track of the async operation purgeCounter.incr(); // Purge the content library as it's no longer needed FoldersContentLibrary.purge(folder, function(err) { if (err) { log().error({'err': err, 'folderId': folder.id, 'folderGroupId': folder.groupId}, 'Unable to purge a folder content library'); } // At this point the async operation is over purgeCounter.decr(); }); });