From 0b2f03d3712f438f67eccf86b67acd047284f9b4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 19 Nov 2018 15:21:09 +0100 Subject: Speedup peertube startup --- server/lib/user.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'server/lib') diff --git a/server/lib/user.ts b/server/lib/user.ts index db29469eb..acb883e23 100644 --- a/server/lib/user.ts +++ b/server/lib/user.ts @@ -17,8 +17,10 @@ async function createUserAccountAndChannel (userToCreate: UserModel, validateUse validate: validateUser } - const userCreated = await userToCreate.save(userOptions) - const accountCreated = await createLocalAccountWithoutKeys(userToCreate.username, userToCreate.id, null, t) + const [ userCreated, accountCreated ] = await Promise.all([ + userToCreate.save(userOptions), + createLocalAccountWithoutKeys(userToCreate.username, userToCreate.id, null, t) + ]) userCreated.Account = accountCreated let channelName = userCreated.username + '_channel' @@ -37,8 +39,13 @@ async function createUserAccountAndChannel (userToCreate: UserModel, validateUse return { user: userCreated, account: accountCreated, videoChannel } }) - account.Actor = await setAsyncActorKeys(account.Actor) - videoChannel.Actor = await setAsyncActorKeys(videoChannel.Actor) + const [ accountKeys, channelKeys ] = await Promise.all([ + setAsyncActorKeys(account.Actor), + setAsyncActorKeys(videoChannel.Actor) + ]) + + account.Actor = accountKeys + videoChannel.Actor = channelKeys return { user, account, videoChannel } as { user: UserModel, account: AccountModel, videoChannel: VideoChannelModel } } -- cgit v1.2.3