refactor(storage): scope exports by owner
CI and Deploy / test (pull_request) Successful in 5m24s
CI and Deploy / deploy (pull_request) Has been skipped

This commit is contained in:
cesnimda
2026-08-15 18:19:59 +02:00
parent 0d487123af
commit cdcc7163fa
17 changed files with 123 additions and 38 deletions
@@ -1,5 +1,3 @@
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using JobTrackerApi.Data;
using JobTrackerApi.Models;
@@ -96,10 +94,9 @@ public sealed class DailyExportHostedService(
Rules = await RulesEngine.GetSettings(db, cancellationToken),
};
var folder = paths.GetExportsRoot(configuration["Exports:DailyFolder"]);
var folder = paths.GetOwnerDailyExportsRoot(configuration["Exports:DailyFolder"], owner);
Directory.CreateDirectory(folder);
var ownerKey = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(owner))).ToLowerInvariant();
var finalPath = Path.Combine(folder, $"daily_export_{ownerKey}_{DateTime.Now:yyyyMMdd}.json");
var finalPath = Path.Combine(folder, $"daily_export_{DateTime.Now:yyyyMMdd}.json");
var temporaryPath = finalPath + $".{Guid.NewGuid():N}.tmp";
try
{