Revision a64c87c8 trunk/Pithos.Core/FileState.cs
b/trunk/Pithos.Core/FileState.cs | ||
---|---|---|
104 | 104 |
if (String.IsNullOrWhiteSpace(algorithm)) |
105 | 105 |
throw new ArgumentNullException("algorithm"); |
106 | 106 |
Contract.EndContractBlock(); |
107 |
|
|
107 |
|
|
108 | 108 |
//Skip updating the hash for folders |
109 | 109 |
if (Directory.Exists(FilePath)) |
110 |
return Task.Factory.StartNew(() => this);
|
|
110 |
return Task.Factory.FromResult(this);
|
|
111 | 111 |
|
112 | 112 |
var results=Task.Factory.TrackedSequence( |
113 | 113 |
() => Task.Factory.StartNew(() => Signature.CalculateMD5(FilePath)), |
114 | 114 |
() => Signature.CalculateTreeHashAsync(FilePath, blockSize, algorithm) |
115 |
);
|
|
115 |
); |
|
116 | 116 |
|
117 |
results.ContinueWith(t =>
|
|
117 |
var state=results.Then(hashes =>
|
|
118 | 118 |
{ |
119 |
var hashes = t.Result; |
|
120 | 119 |
Checksum = (hashes[0] as Task<string>).Result; |
121 |
TopHash = (hashes[0] as Task<TreeHash>).Result.TopHash.ToHashString(); |
|
120 |
TopHash = (hashes[1] as Task<TreeHash>).Result.TopHash.ToHashString(); |
|
121 |
return Task.Factory.FromResult(this); |
|
122 | 122 |
}); |
123 | 123 |
|
124 |
return results.ContinueWith(t => this);
|
|
124 |
return state;
|
|
125 | 125 |
} |
126 | 126 |
} |
127 | 127 |
|
Also available in: Unified diff