add some logging, fix cache handling on load
This commit is contained in:
		| @@ -47,7 +47,7 @@ public class FileCacheManager : IDisposable | |||||||
|                     var hash = splittedEntry[0]; |                     var hash = splittedEntry[0]; | ||||||
|                     var path = splittedEntry[1]; |                     var path = splittedEntry[1]; | ||||||
|                     var time = splittedEntry[2]; |                     var time = splittedEntry[2]; | ||||||
|                     FileCaches[path] = new FileCacheEntity(hash, path, time); |                     FileCaches[path] = ReplacePathPrefixes(new FileCacheEntity(hash, path, time)); | ||||||
|                 } |                 } | ||||||
|                 catch (Exception) |                 catch (Exception) | ||||||
|                 { |                 { | ||||||
| @@ -112,8 +112,8 @@ public class FileCacheManager : IDisposable | |||||||
|  |  | ||||||
|     public FileCacheEntity? GetFileCacheByPath(string path) |     public FileCacheEntity? GetFileCacheByPath(string path) | ||||||
|     { |     { | ||||||
|         var cleanedPath = path.Replace("/", "\\", StringComparison.Ordinal).ToLowerInvariant().Replace(_ipcManager.PenumbraModDirectory()!.ToLowerInvariant(), "", StringComparison.Ordinal); |         var cleanedPath = path.Replace("/", "\\", StringComparison.OrdinalIgnoreCase).ToLowerInvariant().Replace(_ipcManager.PenumbraModDirectory()!.ToLowerInvariant(), "", StringComparison.OrdinalIgnoreCase); | ||||||
|         var entry = FileCaches.FirstOrDefault(f => f.Value.ResolvedFilepath.EndsWith(cleanedPath, StringComparison.Ordinal)).Value; |         var entry = FileCaches.FirstOrDefault(f => f.Value.ResolvedFilepath.EndsWith(cleanedPath, StringComparison.OrdinalIgnoreCase)).Value; | ||||||
|  |  | ||||||
|         if (entry == null) |         if (entry == null) | ||||||
|         { |         { | ||||||
|   | |||||||
| @@ -39,15 +39,20 @@ public class TransientResourceManager : IDisposable | |||||||
|         { |         { | ||||||
|             var persistentEntities = File.ReadAllLines(PersistentDataCache); |             var persistentEntities = File.ReadAllLines(PersistentDataCache); | ||||||
|             SemiTransientResources.TryAdd(ObjectKind.Player, new HashSet<FileReplacement>()); |             SemiTransientResources.TryAdd(ObjectKind.Player, new HashSet<FileReplacement>()); | ||||||
|  |             int restored = 0; | ||||||
|             foreach (var line in persistentEntities) |             foreach (var line in persistentEntities) | ||||||
|             { |             { | ||||||
|                 var fileReplacement = fileReplacementFactory.Create(); |                 var fileReplacement = fileReplacementFactory.Create(); | ||||||
|                 fileReplacement.ResolvePath(line); |                 fileReplacement.ResolvePath(line); | ||||||
|                 if (fileReplacement.HasFileReplacement) |                 if (fileReplacement.HasFileReplacement) | ||||||
|                 { |                 { | ||||||
|  |                     Logger.Debug("Loaded persistent transient resource " + line); | ||||||
|                     SemiTransientResources[ObjectKind.Player].Add(fileReplacement); |                     SemiTransientResources[ObjectKind.Player].Add(fileReplacement); | ||||||
|  |                     restored++; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             Logger.Debug($"Restored {restored}/{persistentEntities.Count()} semi persistent resources"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ using MareSynchronos.API; | |||||||
| using System.Text.RegularExpressions; | using System.Text.RegularExpressions; | ||||||
| using MareSynchronos.FileCache; | using MareSynchronos.FileCache; | ||||||
| using MareSynchronos.Managers; | using MareSynchronos.Managers; | ||||||
| using System; | using MareSynchronos.Utils; | ||||||
|  |  | ||||||
| namespace MareSynchronos.Models; | namespace MareSynchronos.Models; | ||||||
|  |  | ||||||
| @@ -50,15 +50,24 @@ public class FileReplacement | |||||||
|         if (!IsFileSwap) |         if (!IsFileSwap) | ||||||
|         { |         { | ||||||
|             var cache = fileDbManager.GetFileCacheByPath(ResolvedPath); |             var cache = fileDbManager.GetFileCacheByPath(ResolvedPath); | ||||||
|             if (cache == null) return false; |             if (cache == null) | ||||||
|  |             { | ||||||
|  |                 Logger.Warn("Replacement Failed verification: " + GamePaths.First()); | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|             Hash = cache.Hash; |             Hash = cache.Hash; | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         var resolvedPath = fileDbManager.ResolveFileReplacement(GamePaths.First()); |         ResolvePath(GamePaths.First()); | ||||||
|         ResolvedPath = resolvedPath.ToLowerInvariant(); |  | ||||||
|  |  | ||||||
|         return IsFileSwap; |         var success = IsFileSwap; | ||||||
|  |         if (!success) | ||||||
|  |         { | ||||||
|  |             Logger.Warn("FileSwap Failed verification: " + GamePaths.First()); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return success; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public FileReplacementDto ToFileReplacementDto() |     public FileReplacementDto ToFileReplacementDto() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 rootdarkarchon
					rootdarkarchon