about summary refs log tree commit diff
path: root/LibMatrix/Services/ServiceInstaller.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LibMatrix/Services/ServiceInstaller.cs16
1 files changed, 10 insertions, 6 deletions
diff --git a/LibMatrix/Services/ServiceInstaller.cs b/LibMatrix/Services/ServiceInstaller.cs
index 96a1963..b1c98e1 100644
--- a/LibMatrix/Services/ServiceInstaller.cs
+++ b/LibMatrix/Services/ServiceInstaller.cs
@@ -9,14 +9,18 @@ public static class ServiceInstaller {
         if (!services.Any(x => x.ServiceType == typeof(TieredStorageService)))
             throw new Exception("[MRUCore/DI] No TieredStorageService has been registered!");
         //Add config
-        if(config is not null)
-            services.AddSingleton(config);
-        else {
-            services.AddSingleton(new RoryLibMatrixConfiguration());
-        }
+        services.AddSingleton(config ?? new RoryLibMatrixConfiguration());
+
         //Add services
-        services.AddSingleton<HomeserverProviderService>();
         services.AddSingleton<HomeserverResolverService>();
+
+        if (services.First(x => x.ServiceType == typeof(TieredStorageService)).Lifetime == ServiceLifetime.Singleton) {
+            services.AddSingleton<HomeserverProviderService>();
+        }
+        else {
+            services.AddScoped<HomeserverProviderService>();
+        }
+
         // services.AddScoped<MatrixHttpClient>();
         return services;
     }