Release Testing Final Stretch (#1952)

* Fixed a bug breaking ability to save server settings

* Fixed a case where if a user updated appsetting.json, the DB wouldn't update to stay in alignment.
This commit is contained in:
Joe Milazzo 2023-05-02 19:59:30 -05:00 committed by GitHub
parent 2d842f3783
commit b7c9762956
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -32,6 +32,7 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.ResponseCompression; using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.AspNetCore.StaticFiles; using Microsoft.AspNetCore.StaticFiles;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
@ -294,8 +295,17 @@ public class Startup
{ {
// We don't update the index.html in local as we don't serve from there // We don't update the index.html in local as we don't serve from there
UpdateBaseUrlInIndex(basePath); UpdateBaseUrlInIndex(basePath);
}
// Update DB with what's in config
var dataContext = serviceProvider.GetRequiredService<DataContext>();
var setting = dataContext.ServerSetting.SingleOrDefault(x => x.Key == ServerSettingKey.BaseUrl);
if (setting != null)
{
setting.Value = basePath;
}
dataContext.SaveChanges();
}
app.UseRouting(); app.UseRouting();

View File

@ -2,5 +2,5 @@
"TokenKey": "super secret unguessable key", "TokenKey": "super secret unguessable key",
"Port": 5000, "Port": 5000,
"IpAddresses": "", "IpAddresses": "",
"BaseUrl": "/" "BaseUrl": "/joe/"
} }

View File

@ -83,7 +83,7 @@ export class ManageSettingsComponent implements OnInit {
async saveSettings() { async saveSettings() {
const modelSettings = this.settingsForm.value; const modelSettings = this.settingsForm.value;
modelSettings.bookmarksDirectory = this.serverSettings.bookmarksDirectory;
this.settingsService.updateServerSettings(modelSettings).pipe(take(1)).subscribe((settings: ServerSettings) => { this.settingsService.updateServerSettings(modelSettings).pipe(take(1)).subscribe((settings: ServerSettings) => {
this.serverSettings = settings; this.serverSettings = settings;
this.resetForm(); this.resetForm();