From e7e0937ae592c97ee38bb837579c413ef8f03419 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 14 Nov 2017 17:34:15 +0100 Subject: [PATCH] Multiple access to files in TBF/CameraBinaryFiles prevented, ver. 2.17.732 --- .../Network/Camera/CLP1611/Camera.cs | 37 +++++++++++-------- TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/TestBenchFramework/BenchControl/Network/Camera/CLP1611/Camera.cs b/TestBenchFramework/BenchControl/Network/Camera/CLP1611/Camera.cs index 7d0c866cb..8aa1613e5 100644 --- a/TestBenchFramework/BenchControl/Network/Camera/CLP1611/Camera.cs +++ b/TestBenchFramework/BenchControl/Network/Camera/CLP1611/Camera.cs @@ -41,6 +41,10 @@ namespace TBF.BenchControl.Network.Camera.CLP1611 const string ClpUserName = "tbf"; const string ClpPassword = "C1ern4V0d4"; + + private static Object fileUploadLock = new Object(); + + /// /// Properties /// @@ -433,26 +437,29 @@ namespace TBF.BenchControl.Network.Camera.CLP1611 foreach (FileInfo fi in dirInfo.GetFiles()) { - FileStream fs = fi.Open(FileMode.Open); - fs.Position = 0; - byte[] sha1 = sha1calculator.ComputeHash(fs); - fs.Close(); - - sha1str.Clear(); - foreach (var b in sha1) sha1str.Append(b.ToString("x2")); - - if (!sha1sumResponse.Contains(string.Format("{0} clp/{1}", sha1str, fi.Name))) + lock (fileUploadLock) { - /// Copy a file to the camera if SHA1 sum is different of the file is missing - log.InfoFormat("{0}, IP={1}, Uploading file {2}", Name, IPAddress, fi.Name); - scpClient.Upload(fi, string.Format("clp/{0}", fi.Name)); + FileStream fs = fi.Open(FileMode.Open); + fs.Position = 0; + byte[] sha1 = sha1calculator.ComputeHash(fs); + fs.Close(); - if (!sha1sumResponse.Contains(fi.Name)) + sha1str.Clear(); + foreach (var b in sha1) sha1str.Append(b.ToString("x2")); + + if (!sha1sumResponse.Contains(string.Format("{0} clp/{1}", sha1str, fi.Name))) { - /// Change file properties if it was a new file - sshClient.CreateCommand(string.Format("chmod 755 clp/{0}", fi.Name)).Execute(); + /// Copy a file to the camera if SHA1 sum is different of the file is missing + log.InfoFormat("{0}, IP={1}, Uploading file {2}", Name, IPAddress, fi.Name); + scpClient.Upload(fi, string.Format("clp/{0}", fi.Name)); } } + + if (!sha1sumResponse.Contains(fi.Name)) + { + /// Change file properties if it was a new file + sshClient.CreateCommand(string.Format("chmod 755 clp/{0}", fi.Name)).Execute(); + } } } diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 4f9d33f29..ccec030ba 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.17.731.1")] -[assembly: AssemblyFileVersion("2.17.731.1")] +[assembly: AssemblyVersion("2.17.732.1")] +[assembly: AssemblyFileVersion("2.17.732.1")]