diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-06-01 21:13:43 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-06-01 21:13:43 +0200 |
| commit | 9383a2fb09ffb60cfe63683106945bd688affa59 (patch) | |
| tree | 65b3f4b48841583e355887db5de5a16e7005fc87 /src/BackgroundServices/StartupTasksBackgroundService.cs | |
| download | vinjesvingenhandel.no-9383a2fb09ffb60cfe63683106945bd688affa59.tar.xz vinjesvingenhandel.no-9383a2fb09ffb60cfe63683106945bd688affa59.zip | |
feat: Initial commit after clean slate
Diffstat (limited to 'src/BackgroundServices/StartupTasksBackgroundService.cs')
| -rw-r--r-- | src/BackgroundServices/StartupTasksBackgroundService.cs | 35 |
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 |
