aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Services
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-11-21 11:08:48 +0800
committercrupest <crupest@outlook.com>2022-11-21 11:08:48 +0800
commit7e44b56ec4112f5e131c7fb96838b18550a62c85 (patch)
treee3e55a3984664fc60f51b10a37c321aabd38f17d /BackEnd/Timeline/Services
parent473720658913997919c680df6c82a75d429711d1 (diff)
downloadtimeline-7e44b56ec4112f5e131c7fb96838b18550a62c85.tar.gz
timeline-7e44b56ec4112f5e131c7fb96838b18550a62c85.tar.bz2
timeline-7e44b56ec4112f5e131c7fb96838b18550a62c85.zip
Fix #1354 #1355 .
Diffstat (limited to 'BackEnd/Timeline/Services')
-rw-r--r--BackEnd/Timeline/Services/DatabaseManagement/DatabaseManagementService.cs11
1 files changed, 9 insertions, 2 deletions
diff --git a/BackEnd/Timeline/Services/DatabaseManagement/DatabaseManagementService.cs b/BackEnd/Timeline/Services/DatabaseManagement/DatabaseManagementService.cs
index c3d9ac4e..a4814069 100644
--- a/BackEnd/Timeline/Services/DatabaseManagement/DatabaseManagementService.cs
+++ b/BackEnd/Timeline/Services/DatabaseManagement/DatabaseManagementService.cs
@@ -1,9 +1,11 @@
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading;
using System.Threading.Tasks;
+using Timeline.Configs;
using Timeline.Entities;
namespace Timeline.Services.DatabaseManagement
@@ -11,10 +13,12 @@ namespace Timeline.Services.DatabaseManagement
public class DatabaseManagementService : IHostedService
{
private readonly IServiceProvider _serviceProvider;
+ private readonly bool _disableAutoBackup;
- public DatabaseManagementService(IServiceProvider serviceProvider)
+ public DatabaseManagementService(IServiceProvider serviceProvider, IConfiguration configuration)
{
_serviceProvider = serviceProvider;
+ _disableAutoBackup = ApplicationConfiguration.GetBoolConfig(configuration, ApplicationConfiguration.DisableAutoBackupKey, false);
}
public async Task StartAsync(CancellationToken cancellationToken = default)
@@ -27,7 +31,10 @@ namespace Timeline.Services.DatabaseManagement
var customMigrator = provider.GetRequiredService<IDatabaseCustomMigrator>();
- await backupService.BackupAsync(cancellationToken);
+ if (!_disableAutoBackup)
+ {
+ await backupService.BackupAsync(cancellationToken);
+ }
await database.Database.MigrateAsync(cancellationToken);
await customMigrator.MigrateAsync(cancellationToken);
}