From 1e67b3c13c10b9b90088eac596ec5002d236c2ea Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Fri, 26 Nov 2021 09:27:57 +0900 Subject: [PATCH] Create local instance user on caching if it doesn't exist --- plume-models/src/instance.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plume-models/src/instance.rs b/plume-models/src/instance.rs index e791cb67..5f9ef5a7 100644 --- a/plume-models/src/instance.rs +++ b/plume-models/src/instance.rs @@ -109,8 +109,9 @@ impl Instance { } pub fn cache_local_instance_user(conn: &Connection) { - let user = Self::get_local_instance_user_uncached(conn) - .expect("Failed to get local instance user"); + let user = Self::get_local_instance_user_uncached(conn).unwrap_or_else(|_| { + Self::create_local_instance_user(conn).expect("Failed to create local instance user") + }); LOCAL_INSTANCE_USER .set(user) .expect("Failed to set local instance user");