refactor(storage): scope exports by owner
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user