[Identity] Disable polling on file providers (#11048)

* Disable polling on file file providers.
* Use in-memory SQL lite database always on the test project.
This commit is contained in:
Javier Calvarro Nelson 2019-06-11 17:42:04 +02:00 committed by GitHub
parent 85feca7a12
commit c7a9da58b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -42,6 +42,8 @@ namespace Identity.DefaultUI.WebSite
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
StartupBase<IdentityUser,IdentityDbContext>.DisableFilePolling(env);
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();

View File

@ -42,10 +42,11 @@ namespace Identity.DefaultUI.WebSite
services.AddDbContext<TContext>(options => services.AddDbContext<TContext>(options =>
options options
.ConfigureWarnings(b => b.Log(CoreEventId.ManyServiceProvidersCreatedWarning)) .ConfigureWarnings(b => b.Log(CoreEventId.ManyServiceProvidersCreatedWarning))
.UseSqlServer( //.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection"), // Configuration.GetConnectionString("DefaultConnection"),
sqlOptions => sqlOptions.MigrationsAssembly("Identity.DefaultUI.WebSite") // sqlOptions => sqlOptions.MigrationsAssembly("Identity.DefaultUI.WebSite")
)); //));
.UseSqlite("DataSource=:memory:"));
services.AddDefaultIdentity<TUser>() services.AddDefaultIdentity<TUser>()
.AddDefaultUI(Framework) .AddDefaultUI(Framework)
@ -89,10 +90,11 @@ namespace Identity.DefaultUI.WebSite
}); });
} }
protected static void DisableFilePolling(IWebHostEnvironment env) public static void DisableFilePolling(IWebHostEnvironment env)
{ {
var pendingProviders = new Stack<IFileProvider>(); var pendingProviders = new Stack<IFileProvider>();
pendingProviders.Push(env.WebRootFileProvider); pendingProviders.Push(env.WebRootFileProvider);
pendingProviders.Push(env.ContentRootFileProvider);
while (pendingProviders.TryPop(out var currentProvider)) while (pendingProviders.TryPop(out var currentProvider))
{ {
switch (currentProvider) switch (currentProvider)