add version to swf hash

This commit is contained in:
2017-05-27 23:06:42 +07:00
parent f0f18e6aec
commit 26fde9fe89
9 changed files with 43 additions and 8 deletions

View File

@@ -42,7 +42,7 @@ namespace FTEditor.Postprocessors {
}
static void SwfFileProcess(string swf_path) {
var swf_hash = SwfEditorUtils.GetFileHash(swf_path);
var swf_hash = SwfEditorUtils.GetFileHashWithVersion(swf_path);
var swf_asset_path = Path.ChangeExtension(swf_path, ".asset");
SwfEditorUtils.LoadOrCreateAsset<SwfAsset>(swf_asset_path, (swf_asset, created) => {
if ( !string.IsNullOrEmpty(swf_asset.Hash) && swf_asset.Hash == swf_hash ) {

View File

@@ -266,12 +266,20 @@ namespace FTEditor {
//
// ---------------------------------------------------------------------
public static string GetFileHash(string path) {
public static string GetFileHashWithVersion(string path) {
return string.Format(
"{0}={1}",
GetFileHash(path), SwfVersion.AsString);
}
static string GetFileHash(string path) {
try {
using ( var sha256 = SHA256.Create() ) {
var file_bytes = File.ReadAllBytes(path);
var hash_bytes = sha256.ComputeHash(file_bytes);
return System.Convert.ToBase64String(hash_bytes) + file_bytes.LongLength.ToString();
return
System.Convert.ToBase64String(hash_bytes) +
file_bytes.LongLength.ToString();
}
} catch ( System.Exception ) {
return string.Empty;

View File

@@ -0,0 +1,15 @@
namespace FTRuntime {
public static class SwfVersion {
public const int Major = 1;
public const int Minor = 3;
public const int Revision = 8;
public static string AsString {
get {
return string.Format(
"{0}.{1}.{2}",
Major, Minor, Revision);
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9326b7a46761449f7bbb3d857cffacec
timeCreated: 1495899500
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: