summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--win/C#/Functions/Main.cs19
-rw-r--r--win/C#/Properties/Settings.Designer.cs7
-rw-r--r--win/C#/Properties/Settings.settings2
-rw-r--r--win/C#/app.config2
4 files changed, 21 insertions, 9 deletions
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs
index 2edfd1568..8f7cea326 100644
--- a/win/C#/Functions/Main.cs
+++ b/win/C#/Functions/Main.cs
@@ -10,6 +10,7 @@ namespace Handbrake.Functions
using System.Diagnostics;
using System.IO;
using System.Linq;
+ using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
@@ -291,15 +292,22 @@ namespace Handbrake.Functions
// 0 = SVN Build / Version
// 1 = Build Date
- DateTime lastModified = File.GetLastWriteTime("HandBrakeCLI.exe");
- if (Properties.Settings.Default.hb_build != 0 && Properties.Settings.Default.cliLastModified == lastModified)
+ // Get the SHA1 Hash of HandBrakeCLI
+ byte[] hash;
+ using (Stream stream = File.OpenRead("HandBrakeCLI.exe"))
+ {
+ hash = SHA1.Create().ComputeHash(stream);
+ }
+ string base64Hash = Convert.ToBase64String(hash);
+
+ // Compare the hash with the last known hash. If it's the same, return.
+ if (Properties.Settings.Default.CliExeHash == base64Hash)
{
return;
}
- Properties.Settings.Default.cliLastModified = lastModified;
-
+ // It's not the same, so start the CLI to get it's version data.
Process cliProcess = new Process();
ProcessStartInfo handBrakeCli = new ProcessStartInfo("HandBrakeCLI.exe", " -u -v0")
{
@@ -350,11 +358,14 @@ namespace Handbrake.Functions
}
}
+ Properties.Settings.Default.CliExeHash = base64Hash;
+
Properties.Settings.Default.Save();
}
catch (Exception e)
{
Properties.Settings.Default.hb_build = 0;
+ Properties.Settings.Default.CliExeHash = null;
Properties.Settings.Default.Save();
ShowExceptiowWindow("Unable to retrieve version information from the CLI.", e.ToString());
diff --git a/win/C#/Properties/Settings.Designer.cs b/win/C#/Properties/Settings.Designer.cs
index e02976a64..9dad5078d 100644
--- a/win/C#/Properties/Settings.Designer.cs
+++ b/win/C#/Properties/Settings.Designer.cs
@@ -420,12 +420,13 @@ namespace Handbrake.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public global::System.DateTime cliLastModified {
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string CliExeHash {
get {
- return ((global::System.DateTime)(this["cliLastModified"]));
+ return ((string)(this["CliExeHash"]));
}
set {
- this["cliLastModified"] = value;
+ this["CliExeHash"] = value;
}
}
diff --git a/win/C#/Properties/Settings.settings b/win/C#/Properties/Settings.settings
index 563a4ec22..2cd3898de 100644
--- a/win/C#/Properties/Settings.settings
+++ b/win/C#/Properties/Settings.settings
@@ -101,7 +101,7 @@
<Setting Name="growlEncode" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
- <Setting Name="cliLastModified" Type="System.DateTime" Scope="User">
+ <Setting Name="CliExeHash" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="previewScanCount" Type="System.Int32" Scope="User">
diff --git a/win/C#/app.config b/win/C#/app.config
index 3f2c566ed..cea155aab 100644
--- a/win/C#/app.config
+++ b/win/C#/app.config
@@ -110,7 +110,7 @@
<setting name="growlEncode" serializeAs="String">
<value>False</value>
</setting>
- <setting name="cliLastModified" serializeAs="String">
+ <setting name="CliExeHash" serializeAs="String">
<value />
</setting>
<setting name="previewScanCount" serializeAs="String">