Multiple access to files in TBF/CameraBinaryFiles prevented, ver. 2.17.732
This commit is contained in:
parent
0325b0214b
commit
e7e0937ae5
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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")]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user