From 989f24e123d42a5f66536c8760f4849c61eba4f2 Mon Sep 17 00:00:00 2001 From: Archangel Date: Sun, 15 Jun 2025 20:05:44 +0200 Subject: [PATCH] Remove duplicate service --- .../Services/Cache/BundleHashCacheService.cs | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 Libraries/SPTarkov.Server.Core/Services/Cache/BundleHashCacheService.cs diff --git a/Libraries/SPTarkov.Server.Core/Services/Cache/BundleHashCacheService.cs b/Libraries/SPTarkov.Server.Core/Services/Cache/BundleHashCacheService.cs deleted file mode 100644 index 6a5ca0af..00000000 --- a/Libraries/SPTarkov.Server.Core/Services/Cache/BundleHashCacheService.cs +++ /dev/null @@ -1,58 +0,0 @@ -using SPTarkov.DI.Annotations; -using SPTarkov.Server.Core.Models.Utils; -using SPTarkov.Server.Core.Utils; -using LogLevel = SPTarkov.Server.Core.Models.Spt.Logging.LogLevel; - -namespace SPTarkov.Server.Core.Services.Cache; - -[Injectable] -public class BundleHashCacheService( - ISptLogger _logger, - HashUtil _hashUtil, - JsonUtil _jsonUtil, - FileUtil _fileUtil -) -{ - protected static readonly string _bundleHashCachePath = "./user/cache/bundleHashCache.json"; - protected Dictionary _bundleHashes = new(); - - public string GetStoredValue(string key) - { - _bundleHashes.TryGetValue(key, out var value); - - return value; - } - - public void StoreValue(string key, string value) - { - _bundleHashes.Add(key, value); - - _fileUtil.WriteFile(_bundleHashCachePath, _jsonUtil.Serialize(_bundleHashes)); - - if (_logger.IsLogEnabled(LogLevel.Debug)) - { - _logger.Debug($"Bundle {key} hash stored in {_bundleHashCachePath}"); - } - } - - public bool MatchWithStoredHash(string bundlePath, string hash) - { - return GetStoredValue(bundlePath) == hash; - } - - public bool CalculateAndMatchHash(string bundlePath) - { - var fileContents = _fileUtil.ReadFile(bundlePath); - var generatedHash = _hashUtil.GenerateHashForData(HashingAlgorithm.MD5, fileContents); - - return MatchWithStoredHash(bundlePath, generatedHash); - } - - public void CalculateAndStoreHash(string bundlePath) - { - var fileContents = _fileUtil.ReadFile(bundlePath); - var generatedHash = _hashUtil.GenerateHashForData(HashingAlgorithm.MD5, fileContents); - - StoreValue(bundlePath, generatedHash); - } -}