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
+14
View File
@@ -1,5 +1,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using System.Security.Cryptography;
using System.Text;
namespace JobTrackerApi.Services
{
@@ -57,6 +59,18 @@ namespace JobTrackerApi.Services
if (string.IsNullOrWhiteSpace(folder)) return Path.Combine(DataRoot, "exports");
return Path.IsPathRooted(folder) ? folder : Path.Combine(DataRoot, folder);
}
public static string GetOwnerStorageKey(string ownerUserId)
{
ArgumentException.ThrowIfNullOrWhiteSpace(ownerUserId);
return Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(ownerUserId))).ToLowerInvariant();
}
public string GetOwnerCvExportsRoot(string ownerUserId) =>
Path.Combine(CvExportsRoot, GetOwnerStorageKey(ownerUserId));
public string GetOwnerDailyExportsRoot(string? configuredFolder, string ownerUserId) =>
Path.Combine(GetExportsRoot(configuredFolder), GetOwnerStorageKey(ownerUserId));
}
}