Revision b1303755 trunk/Pithos.Core/Agents/PollAgent.cs
b/trunk/Pithos.Core/Agents/PollAgent.cs | ||
---|---|---|
614 | 614 |
{ |
615 | 615 |
//Detect server moves |
616 | 616 |
var targetPath = MoveForServerMove(accountInfo, tuple); |
617 |
StatusKeeper.StoreInfo(targetPath, tuple.ObjectInfo); |
|
617 |
Debug.Assert(tuple.Merkle!=null); |
|
618 |
StatusKeeper.StoreInfo(targetPath, tuple.ObjectInfo,tuple.Merkle); |
|
618 | 619 |
|
619 | 620 |
AddOwnFolderToSelectives(accountInfo, tuple, targetPath); |
620 | 621 |
} |
... | ... | |
675 | 676 |
StatusKeeper.SetFileState(targetPath, FileStatus.Modified, FileOverlayStatus.Modified, |
676 | 677 |
""); |
677 | 678 |
|
678 |
await |
|
679 |
var finalHash=await
|
|
679 | 680 |
NetworkAgent.Downloader.DownloadCloudFile(accountInfo, tuple.ObjectInfo, targetPath, |
680 | 681 |
token) |
681 | 682 |
.ConfigureAwait(false); |
682 | 683 |
//updateRecord( L = S ) |
683 | 684 |
StatusKeeper.UpdateFileChecksum(targetPath, tuple.ObjectInfo.ETag, |
684 |
tuple.ObjectInfo.X_Object_Hash);
|
|
685 |
finalHash);
|
|
685 | 686 |
|
686 |
StatusKeeper.StoreInfo(targetPath, tuple.ObjectInfo); |
|
687 |
StatusKeeper.StoreInfo(targetPath, tuple.ObjectInfo,finalHash);
|
|
687 | 688 |
} |
688 | 689 |
|
689 | 690 |
private async Task UploadLocalFile(AccountInfo accountInfo, StateTuple tuple, CancellationToken token, |
... | ... | |
691 | 692 |
{ |
692 | 693 |
var action = new CloudUploadAction(accountInfo, localInfo, tuple.FileState, |
693 | 694 |
accountInfo.BlockSize, accountInfo.BlockHash, |
694 |
"Poll", isUnselectedRootFolder, token, progress); |
|
695 |
"Poll", isUnselectedRootFolder, token, progress,tuple.Merkle); |
|
696 |
|
|
695 | 697 |
using (StatusNotification.GetNotifier("Uploading {0}", "Uploaded {0}", |
696 | 698 |
localInfo.Name)) |
697 | 699 |
{ |
... | ... | |
814 | 816 |
di.MoveTo(serverPath); |
815 | 817 |
} |
816 | 818 |
} |
817 |
StatusKeeper.StoreInfo(serverPath, tuple.ObjectInfo); |
|
819 |
|
|
820 |
StatusKeeper.StoreInfo(serverPath, tuple.ObjectInfo,null); |
|
818 | 821 |
|
819 | 822 |
return serverPath; |
820 | 823 |
} |
... | ... | |
836 | 839 |
|
837 | 840 |
var dirInfo = tuple.FileInfo as DirectoryInfo; |
838 | 841 |
var folderTuples = from folder in dirInfo.EnumerateDirectories("*", SearchOption.AllDirectories) |
839 |
select new StateTuple(folder){C=Signature.MD5_EMPTY}; |
|
842 |
select new StateTuple(folder){C=Signature.MERKLE_EMPTY}; |
|
843 |
|
|
840 | 844 |
var fileTuples = from file in dirInfo.EnumerateFiles("*", SearchOption.AllDirectories) |
841 |
select new StateTuple(file){C=file.ComputeShortHash(this.StatusNotification)}; |
|
845 |
let state=StatusKeeper.GetStateByFilePath(file.FullName) |
|
846 |
select new StateTuple(file){ |
|
847 |
Merkle=StatusAgent.CalculateTreeHash(file,accountInfo,state, |
|
848 |
Settings.HashingParallelism,token,null) |
|
849 |
}; |
|
842 | 850 |
|
843 | 851 |
//Process folders first, to ensure folders appear on the sever as soon as possible |
844 | 852 |
folderTuples.ApplyAction(t => SyncSingleItem(accountInfo, t, agent, moves, processedPaths,token).Wait()); |
... | ... | |
1019 | 1027 |
var storedDate = state.NullSafe(s => s.LastWriteDate) ?? DateTime.MinValue; |
1020 | 1028 |
var storedLength = state.NullSafe(s => s.LastLength); |
1021 | 1029 |
|
1022 |
var md5Hash = Signature.MD5_EMPTY; |
|
1023 |
var topHash = storedHash ?? Signature.MERKLE_EMPTY; |
|
1024 |
|
|
1030 |
var md5Hash = Signature.MD5_EMPTY; |
|
1025 | 1031 |
var merkle=TreeHash.Empty; |
1032 |
|
|
1026 | 1033 |
if (hashTuple.FileInfo is FileInfo) |
1027 | 1034 |
{ |
1028 |
var file = hashTuple.FileInfo.WithProperCapitalization() as FileInfo; |
|
1035 |
var file = (FileInfo)hashTuple.FileInfo.WithProperCapitalization(); |
|
1036 |
|
|
1029 | 1037 |
//Attributes unchanged? |
1030 |
|
|
1038 |
//LastWriteTime is only accurate to the second |
|
1031 | 1039 |
var unchangedAttributes = file.LastWriteTime - storedDate < TimeSpan.FromSeconds(1) |
1032 | 1040 |
&& storedLength == file.Length; |
1033 | 1041 |
|
1034 |
//Attributes appear unchanged but the file length doesn't match the stored hash |
|
1042 |
//Attributes appear unchanged but the file length doesn't match the stored hash ?
|
|
1035 | 1043 |
var nonEmptyMismatch = unchangedAttributes && |
1036 | 1044 |
(file.Length == 0 ^ storedHash== Signature.MERKLE_EMPTY); |
1037 | 1045 |
|
1038 |
//Missing hashes for NON-EMPTY hash |
|
1046 |
//Missing hashes for NON-EMPTY hash ?
|
|
1039 | 1047 |
var missingHashes = storedHash != Signature.MERKLE_EMPTY && |
1040 | 1048 |
String.IsNullOrWhiteSpace(storedHashes); |
1041 | 1049 |
|
Also available in: Unified diff