Revision 030b9baf trunk/Pithos.Core/Agents/BlockUpdater.cs
b/trunk/Pithos.Core/Agents/BlockUpdater.cs | ||
---|---|---|
48 | 48 |
using System.Threading.Tasks; |
49 | 49 |
using OpenSSL.Crypto; |
50 | 50 |
using Pithos.Network; |
51 |
using Alpha = Alphaleonis.Win32.Filesystem; |
|
51 | 52 |
|
52 | 53 |
namespace Pithos.Core.Agents |
53 | 54 |
{ |
... | ... | |
192 | 193 |
throw new InvalidOperationException("TempPath is empty"); |
193 | 194 |
Contract.EndContractBlock(); |
194 | 195 |
|
195 |
var drive=DriveInfo.GetDrives().First(d => FilePath.StartsWith(d.RootDirectory.FullName));
|
|
196 |
var drive=DriveInfo.GetDrives().First(d => FilePath.StartsWith(d.Name,StringComparison.OrdinalIgnoreCase));
|
|
196 | 197 |
var isNTFS=(drive.DriveFormat == "NTFS"); |
197 | 198 |
|
198 | 199 |
|
199 |
if (MS.WindowsAPICodePack.Internal.CoreHelpers.RunningOnXP ||!isNTFS)
|
|
200 |
if (isNTFS && MS.WindowsAPICodePack.Internal.CoreHelpers.RunningOnVista)
|
|
200 | 201 |
{ |
201 |
ApplyBlocksWithCopy();
|
|
202 |
ApplyBlocksWithTransaction();
|
|
202 | 203 |
} |
203 | 204 |
else |
204 | 205 |
{ |
205 |
ApplyBlocksWithTransaction();
|
|
206 |
ApplyBlocksWithCopy();
|
|
206 | 207 |
} |
207 | 208 |
ClearBlocks(); |
208 | 209 |
} |
209 | 210 |
|
210 | 211 |
private void ApplyBlocksWithTransaction() |
211 | 212 |
{ |
212 |
ApplyBlocksWithCopy(); |
|
213 |
var targetFile = FilePath; |
|
214 |
using (var tx = new Alpha.KernelTransaction()) |
|
215 |
{ |
|
216 |
using ( |
|
217 |
var stream = Alpha.File.Open(tx,targetFile, Alpha.FileMode.OpenOrCreate, |
|
218 |
Alpha.FileAccess.Write)) |
|
219 |
{ |
|
220 |
stream.SetLength(ServerHash.Bytes); |
|
221 |
foreach (var block in _blocks) |
|
222 |
{ |
|
223 |
var blockPath = block.Value; |
|
224 |
var blockIndex = block.Key; |
|
225 |
using (var blockStream = File.OpenRead(blockPath)) |
|
226 |
{ |
|
227 |
long offset = blockIndex*ServerHash.BlockSize; |
|
228 |
stream.Seek(offset, SeekOrigin.Begin); |
|
229 |
blockStream.CopyTo(stream); |
|
230 |
} |
|
231 |
} |
|
232 |
} |
|
233 |
tx.Commit(); |
|
234 |
} |
|
235 |
|
|
213 | 236 |
} |
214 | 237 |
|
215 | 238 |
private void ApplyBlocksWithCopy() |
Also available in: Unified diff