aboutsummaryrefslogtreecommitdiffstats
path: root/src/BackgroundServices/StartupTasksBackgroundService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/BackgroundServices/StartupTasksBackgroundService.cs')
-rw-r--r--src/BackgroundServices/StartupTasksBackgroundService.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/BackgroundServices/StartupTasksBackgroundService.cs b/src/BackgroundServices/StartupTasksBackgroundService.cs
new file mode 100644
index 0000000..8aebee9
--- /dev/null
+++ b/src/BackgroundServices/StartupTasksBackgroundService.cs
@@ -0,0 +1,35 @@
+using System.Collections.Generic;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+using VSH.Data.Static;
+
+namespace VSH.BackgroundServices;
+
+public class StartupTasksBackgroundService : BackgroundService
+{
+ private readonly ILogger<StartupTasksBackgroundService> _logger;
+
+ private static IEnumerable<string> PathsToEnsureCreated => new List<string> {
+ AppPaths.ProductImages.HostPath,
+ AppPaths.DocumentImages.HostPath,
+ };
+
+ public StartupTasksBackgroundService(ILogger<StartupTasksBackgroundService> logger) {
+ _logger = logger;
+ }
+
+ protected override Task ExecuteAsync(CancellationToken stoppingToken) {
+ EnsureCreated();
+ return Task.CompletedTask;
+ }
+
+ private void EnsureCreated() {
+ foreach (var path in PathsToEnsureCreated) {
+ Directory.CreateDirectory(path);
+ _logger.LogInformation("EnsuredCreated: " + path);
+ }
+ }
+} \ No newline at end of file