Reduced buffer size while hashing to 16K
authorpkanavos <pkanavos@gmail.com>
Mon, 2 Jul 2012 10:50:21 +0000 (13:50 +0300)
committerpkanavos <pkanavos@gmail.com>
Mon, 2 Jul 2012 10:50:21 +0000 (13:50 +0300)
trunk/Pithos.Client.WPF/Preferences/PreferencesView.xaml
trunk/Pithos.Core/Agents/BlockExtensions.cs
trunk/Pithos.Network/Signature.cs

index 735082d..afdfdcf 100644 (file)
@@ -9,7 +9,6 @@
         WindowStartupLocation="CenterScreen"
         Icon="/PithosPlus;component/Images/PithosTaskbar.png"
         WindowStyle="ToolWindow"        
-        Topmost="True"
         ResizeMode="NoResize"
         Topmost="True"
         ShowInTaskbar="False"
index 16af092..5688055 100644 (file)
@@ -124,7 +124,7 @@ namespace Pithos.Core.Agents
 
            var progress = new StatusNotification("");
 
-           using (var stream = new FileStream(info.FullName,FileMode.Open, FileAccess.Read, FileShare.Read,65536))
+           using (var stream = new FileStream(info.FullName,FileMode.Open, FileAccess.Read, FileShare.Read,Signature.BufferSize))
            {
                var buffer = new byte[65536];
                int counter=0;
@@ -177,7 +177,7 @@ namespace Pithos.Core.Agents
 
           
 
-           using (var stream = new FileStream(info.FullName,FileMode.Open, FileAccess.Read, FileShare.Read,65536))
+           using (var stream = new FileStream(info.FullName,FileMode.Open, FileAccess.Read, FileShare.Read,Signature.BufferSize))
            {
                int counter=0;
                int bytesRead;
index 6caedf1..3134e8c 100644 (file)
@@ -55,6 +55,7 @@ namespace Pithos.Network
     public static class Signature
     {
         private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+        public const  int BufferSize = 16384;
 
         public const string MD5_EMPTY = "d41d8cd98f00b204e9800998ecf8427e";
 
@@ -85,7 +86,7 @@ namespace Pithos.Network
 
             string hash;
             using (var hasher = MD5.Create())
-            using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 65536, true))
+            using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, Signature.BufferSize, true))
             {
                 var hashBytes = hasher.ComputeHash(stream);
                 hash = hashBytes.ToHashString();
@@ -199,7 +200,7 @@ namespace Pithos.Network
                 return new TreeHash(algorithm);
 
             //Calculate the hash of all blocks using a blockhash iterator
-            using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, blockSize, true))
+            using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, BufferSize, true))
             {
                 var md5 = new MD5BlockCalculator();
                 Action<long, byte[], int> postAction = md5.PostBlock;