1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-17 23:56:05 +02:00

Changed how has checks work

This commit is contained in:
Brian Fiete 2019-11-22 12:27:13 -08:00
parent 788351e178
commit 533ef0856b
5 changed files with 135 additions and 58 deletions

View file

@ -37,7 +37,9 @@ namespace IDE
public String mQueuedContent ~ delete _;
public bool mHadRefusedFileChange;
public bool mFileDeleted;
public SourceHash mLoadedHash;
public MD5Hash mMD5Hash;
public SHA256Hash mSHA256Hash;
public this()
{
@ -85,8 +87,8 @@ namespace IDE
{
var editWidgetContent = (SourceEditWidgetContent)mEditWidget.mEditWidgetContent;
mFileDeleted = !editWidgetContent.Reload(mFilePath, mQueuedContent);
if (editWidgetContent.mSourceViewPanel.mLoadedHash.GetKind() == mLoadedHash.GetKind())
editWidgetContent.mSourceViewPanel.mLoadedHash = mLoadedHash;
/*if (editWidgetContent.mSourceViewPanel.LoadedHash.GetKind() == mLoadedHash.GetKind())
editWidgetContent.mSourceViewPanel.LoadedHash = mLoadedHash;*/
mLastFileTextVersion = mEditWidget.Content.mData.mCurTextVersionId;
}
return true;
@ -137,5 +139,21 @@ namespace IDE
if (--mRefCount == 0)
delete this;
}
public void BuildHash(StringView contents)
{
mMD5Hash = Security.Cryptography.MD5.Hash(.((uint8*)contents.Ptr, contents.Length));
mSHA256Hash = Security.Cryptography.SHA256.Hash(.((uint8*)contents.Ptr, contents.Length));
}
public bool CheckHash(SourceHash sourceHash)
{
switch (sourceHash)
{
case .MD5(let hash): return hash == mMD5Hash;
case .SHA256(let hash): return hash == mSHA256Hash;
default: return false;
}
}
}
}