mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Fix mod presets being deleted when changed
This commit is contained in:
parent
1ab19770b9
commit
4c0e7f5896
@ -563,6 +563,7 @@ namespace Bloxstrap
|
|||||||
private static void CheckModPreset(bool condition, string location, string base64Contents)
|
private static void CheckModPreset(bool condition, string location, string base64Contents)
|
||||||
{
|
{
|
||||||
string modFolderLocation = Path.Combine(Directories.Modifications, location);
|
string modFolderLocation = Path.Combine(Directories.Modifications, location);
|
||||||
|
byte[] binaryData = Convert.FromBase64String(base64Contents);
|
||||||
|
|
||||||
if (condition)
|
if (condition)
|
||||||
{
|
{
|
||||||
@ -575,10 +576,10 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
Directory.CreateDirectory(directory);
|
Directory.CreateDirectory(directory);
|
||||||
|
|
||||||
File.WriteAllBytes(modFolderLocation, Convert.FromBase64String(base64Contents));
|
File.WriteAllBytes(modFolderLocation, binaryData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (File.Exists(modFolderLocation))
|
else if (File.Exists(modFolderLocation) && Utilities.MD5File(modFolderLocation) == Utilities.MD5Data(binaryData))
|
||||||
{
|
{
|
||||||
File.Delete(modFolderLocation);
|
File.Delete(modFolderLocation);
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,15 @@ namespace Bloxstrap.Helpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string MD5Data(byte[] data)
|
||||||
|
{
|
||||||
|
using (MD5 md5 = MD5.Create())
|
||||||
|
{
|
||||||
|
byte[] hash = md5.ComputeHash(data);
|
||||||
|
return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// quick and hacky way of getting a value from any key/value pair formatted list
|
// quick and hacky way of getting a value from any key/value pair formatted list
|
||||||
// (command line args, uri params, etc)
|
// (command line args, uri params, etc)
|
||||||
public static string? GetKeyValue(string subject, string key, char delimiter)
|
public static string? GetKeyValue(string subject, string key, char delimiter)
|
||||||
|
Loading…
Reference in New Issue
Block a user