Service sessionIDs to mongoIDs (#454)
* Start updating service sessionIDs to mongoIDs * Finish service conversion + fix other small issues
This commit is contained in:
@@ -5,28 +5,16 @@ using SPTarkov.Server.Core.Utils;
|
||||
namespace SPTarkov.Server.Core.Services;
|
||||
|
||||
[Injectable(InjectionType.Singleton)]
|
||||
public class BundleHashCacheService
|
||||
public class BundleHashCacheService(
|
||||
ISptLogger<BundleHashCacheService> logger,
|
||||
JsonUtil jsonUtil,
|
||||
HashUtil hashUtil,
|
||||
FileUtil fileUtil
|
||||
)
|
||||
{
|
||||
protected const string _bundleHashCachePath = "./user/cache/";
|
||||
protected const string _cacheName = "bundleHashCache.json";
|
||||
protected readonly Dictionary<string, uint> _bundleHashes = new();
|
||||
private readonly FileUtil _fileUtil;
|
||||
private readonly HashUtil _hashUtil;
|
||||
private readonly JsonUtil _jsonUtil;
|
||||
private readonly ISptLogger<BundleHashCacheService> _logger;
|
||||
|
||||
public BundleHashCacheService(
|
||||
ISptLogger<BundleHashCacheService> logger,
|
||||
JsonUtil jsonUtil,
|
||||
HashUtil hashUtil,
|
||||
FileUtil fileUtil
|
||||
)
|
||||
{
|
||||
_logger = logger;
|
||||
_jsonUtil = jsonUtil;
|
||||
_hashUtil = hashUtil;
|
||||
_fileUtil = fileUtil;
|
||||
}
|
||||
|
||||
public uint GetStoredValue(string key)
|
||||
{
|
||||
@@ -47,12 +35,12 @@ public class BundleHashCacheService
|
||||
Directory.CreateDirectory(_bundleHashCachePath);
|
||||
}
|
||||
|
||||
_fileUtil.WriteFile(
|
||||
fileUtil.WriteFile(
|
||||
Path.Join(_bundleHashCachePath, _cacheName),
|
||||
_jsonUtil.Serialize(_bundleHashes)
|
||||
jsonUtil.Serialize(_bundleHashes)
|
||||
);
|
||||
|
||||
_logger.Debug($"Bundle: {bundlePath} hash stored in: ${_bundleHashCachePath}");
|
||||
logger.Debug($"Bundle: {bundlePath} hash stored in: ${_bundleHashCachePath}");
|
||||
}
|
||||
|
||||
public bool CalculateAndMatchHash(string BundlePath)
|
||||
@@ -67,8 +55,8 @@ public class BundleHashCacheService
|
||||
|
||||
public uint CalculateHash(string BundlePath)
|
||||
{
|
||||
var fileData = _fileUtil.ReadFile(BundlePath);
|
||||
return _hashUtil.GenerateCrc32ForData(fileData);
|
||||
var fileData = fileUtil.ReadFile(BundlePath);
|
||||
return hashUtil.GenerateCrc32ForData(fileData);
|
||||
}
|
||||
|
||||
public bool MatchWithStoredHash(string BundlePath, uint hash)
|
||||
|
||||
Reference in New Issue
Block a user