Added check for last MD5 modification, to avoid redundant recalculation of MD5
[pithos-ms-client] / trunk / Pithos.Network / BlockHashAlgorithms.cs
index 70f0629..84f582f 100644 (file)
@@ -230,7 +230,7 @@ namespace Pithos.Network
             return _bufferMgr;\r
         }\r
 \r
-        public static async Task<ConcurrentDictionary<long, byte[]>> CalculateBlockHashesInPlacePFor(FileStream stream, int blockSize, string algorithm, int parallelism)\r
+        public static async Task<ConcurrentDictionary<long, byte[]>> CalculateBlockHashesInPlacePFor(FileStream stream, int blockSize, string algorithm, int parallelism,IProgress<double> progress )\r
         {\r
             if (stream == null)\r
                 throw new ArgumentNullException("stream");\r
@@ -274,7 +274,7 @@ namespace Pithos.Network
                 long index = 0;\r
 \r
 \r
-                while ((read = await stream.ReadAsync(buffer[bufIdx], 0, blockSize)) > 0)\r
+                while ((read = await stream.ReadAsync(buffer[bufIdx], 0, blockSize).ConfigureAwait(false)) > 0)\r
                 {\r
                     index += read;\r
                     indices[bufIdx] = index;\r
@@ -302,6 +302,7 @@ namespace Pithos.Network
                                                                                 (double)filePosition / size);\r
                             */\r
                                                             hashes[filePosition] = hash;\r
+                                                            progress.Report((long)hashes.Count*blockSize*1.0/stream.Length);\r
                                                         });\r
                     }\r
                     bufIdx = (bufIdx + 1)%parallelism;\r