diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-11-30 22:51:50 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-11-30 22:51:50 -0500 |
commit | 33f46d26f476914045d5fa5cc798a1fafa3480d8 (patch) | |
tree | 20e3d9eb6b7660cf2a6d3b3df77d1a49afc8a875 | |
parent | 44dfb6fac5650aa2c10cc76832d836a440ad8a2d (diff) | |
download | SMAPI-33f46d26f476914045d5fa5cc798a1fafa3480d8.tar.gz SMAPI-33f46d26f476914045d5fa5cc798a1fafa3480d8.tar.bz2 SMAPI-33f46d26f476914045d5fa5cc798a1fafa3480d8.zip |
invalidate assembly rewrite cache on new SMAPI version (#166)
-rw-r--r-- | src/StardewModdingAPI/Framework/ModAssemblyLoader.cs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/StardewModdingAPI/Framework/ModAssemblyLoader.cs b/src/StardewModdingAPI/Framework/ModAssemblyLoader.cs index 6c5e6032..c5f9ec31 100644 --- a/src/StardewModdingAPI/Framework/ModAssemblyLoader.cs +++ b/src/StardewModdingAPI/Framework/ModAssemblyLoader.cs @@ -51,11 +51,11 @@ namespace StardewModdingAPI.Framework string assemblyFileName = Path.GetFileName(assemblyPath); string assemblyDir = Path.GetDirectoryName(assemblyPath); byte[] assemblyBytes = File.ReadAllBytes(assemblyPath); - byte[] hash = MD5.Create().ComputeHash(assemblyBytes); + string hash = $"SMAPI {Constants.Version}|" + string.Join("", MD5.Create().ComputeHash(assemblyBytes).Select(p => p.ToString("X2"))); // check cache CachePaths cachePaths = this.GetCacheInfo(assemblyPath); - bool canUseCache = File.Exists(cachePaths.Assembly) && File.Exists(cachePaths.Hash) && hash.SequenceEqual(File.ReadAllBytes(cachePaths.Hash)); + bool canUseCache = File.Exists(cachePaths.Assembly) && File.Exists(cachePaths.Hash) && hash == File.ReadAllText(cachePaths.Hash); // process assembly if not cached if (!canUseCache) @@ -80,7 +80,7 @@ namespace StardewModdingAPI.Framework // write assembly data Directory.CreateDirectory(cachePaths.Directory); File.WriteAllBytes(cachePaths.Assembly, outBytes); - File.WriteAllBytes(cachePaths.Hash, hash); + File.WriteAllText(cachePaths.Hash, hash); // copy any mdb/pdb files foreach (string path in Directory.GetFiles(assemblyDir, "*.mdb").Concat(Directory.GetFiles(assemblyDir, "*.pdb"))) |