Revision bc27bb7e
b/trunk/Pithos.Client.WPF/FileProperties/ConflictsViewModel.cs | ||
---|---|---|
108 | 108 |
|
109 | 109 |
} |
110 | 110 |
|
111 |
protected override void OnViewLoaded(object view) |
|
112 |
{ |
|
113 |
base.OnViewLoaded(view); |
|
114 |
StatusKeeper.CleanupOrphanStates(); |
|
115 |
} |
|
116 |
|
|
111 | 117 |
/// <summary> |
112 | 118 |
/// Open an explorer window to the target path's directory |
113 | 119 |
/// and select the file |
... | ... | |
142 | 148 |
{ |
143 | 149 |
void Resolve(IEnumerable<ConflictFile> conflicts); |
144 | 150 |
} |
151 |
|
|
152 |
[Export(typeof(IConflictResolver))] |
|
153 |
public class DummyResolver:IConflictResolver |
|
154 |
{ |
|
155 |
public void Resolve(IEnumerable<ConflictFile> conflicts) |
|
156 |
{ |
|
157 |
|
|
158 |
} |
|
159 |
} |
|
145 | 160 |
} |
b/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs | ||
---|---|---|
525 | 525 |
} |
526 | 526 |
public void ShowConflicts() |
527 | 527 |
{ |
528 |
_windowManager.ShowWindow(new ConflictsViewModel());
|
|
528 |
_windowManager.ShowWindow(IoC.Get<ConflictsViewModel>());
|
|
529 | 529 |
} |
530 | 530 |
|
531 | 531 |
/// <summary> |
b/trunk/Pithos.Core.Test/MockStatusKeeper.cs | ||
---|---|---|
206 | 206 |
FileStatus value; |
207 | 207 |
_statusCache.TryRemove(path,out value); |
208 | 208 |
} |
209 |
|
|
210 |
|
|
211 |
public void CleanupStaleStates(AccountInfo accountInfo, List<ObjectInfo> objectInfos) |
|
212 |
{ |
|
213 |
//throw new NotImplementedException(); |
|
214 |
} |
|
215 |
|
|
216 |
|
|
217 |
public void CleanupOrphanStates() |
|
218 |
{ |
|
219 |
throw new NotImplementedException(); |
|
220 |
} |
|
209 | 221 |
} |
210 | 222 |
} |
b/trunk/Pithos.Core/Agents/PollAgent.cs | ||
---|---|---|
268 | 268 |
StringComparison.InvariantCultureIgnoreCase) |
269 | 269 |
select info).ToList(); |
270 | 270 |
|
271 |
if (_firstPoll) |
|
272 |
StatusKeeper.CleanupOrphanStates(); |
|
273 |
StatusKeeper.CleanupStaleStates(accountInfo, cleanRemotes); |
|
274 |
|
|
271 | 275 |
var differencer = _differencer.PostSnapshot(accountInfo, cleanRemotes); |
272 | 276 |
|
273 | 277 |
var filterUris = SelectiveUris[accountInfo.AccountKey]; |
b/trunk/Pithos.Core/Agents/StatusAgent.cs | ||
---|---|---|
844 | 844 |
_persistenceAgent.Post(() => FileState.UpdateChecksum(path, shortHash,checksum)); |
845 | 845 |
} |
846 | 846 |
|
847 |
|
|
848 |
public void CleanupOrphanStates() |
|
849 |
{ |
|
850 |
//Orphan states are those that do not correspond to an account, ie. their paths |
|
851 |
//do not start with the root path of any registered account |
|
852 |
|
|
853 |
var roots=(from account in Settings.Accounts |
|
854 |
select account.RootPath).ToList(); |
|
855 |
|
|
856 |
var allStates = from state in FileState.Queryable |
|
857 |
select state.FilePath; |
|
858 |
|
|
859 |
foreach (var statePath in allStates) |
|
860 |
{ |
|
861 |
if (!roots.Any(root=>statePath.StartsWith(root,StringComparison.InvariantCultureIgnoreCase))) |
|
862 |
this.DeleteDirect(statePath); |
|
863 |
} |
|
864 |
} |
|
865 |
|
|
866 |
public void CleanupStaleStates(AccountInfo accountInfo, List<ObjectInfo> objectInfos) |
|
867 |
{ |
|
868 |
if (accountInfo == null) |
|
869 |
throw new ArgumentNullException("accountInfo"); |
|
870 |
if (objectInfos == null) |
|
871 |
throw new ArgumentNullException("objectInfos"); |
|
872 |
Contract.EndContractBlock(); |
|
873 |
|
|
874 |
|
|
875 |
|
|
876 |
//Stale states are those that have no corresponding local or server file |
|
877 |
|
|
878 |
|
|
879 |
var agent=FileAgent.GetFileAgent(accountInfo); |
|
880 |
|
|
881 |
var localFiles=agent.EnumerateFiles(); |
|
882 |
var localSet = new HashSet<string>(localFiles); |
|
883 |
|
|
884 |
var serverFiles = from info in objectInfos |
|
885 |
select Path.Combine(accountInfo.AccountPath,info.RelativeUrlToFilePath(accountInfo.UserName)); |
|
886 |
var serverSet = new HashSet<string>(serverFiles); |
|
887 |
|
|
888 |
var allStates = from state in FileState.Queryable |
|
889 |
where state.FilePath.StartsWith(agent.RootPath) |
|
890 |
select state.FilePath; |
|
891 |
var stateSet = new HashSet<string>(allStates); |
|
892 |
stateSet.ExceptWith(serverSet); |
|
893 |
stateSet.ExceptWith(localSet); |
|
894 |
|
|
895 |
foreach (var remainder in stateSet) |
|
896 |
{ |
|
897 |
DeleteDirect(remainder); |
|
898 |
} |
|
899 |
|
|
900 |
|
|
901 |
} |
|
847 | 902 |
} |
848 | 903 |
|
849 | 904 |
|
b/trunk/Pithos.Core/IStatusKeeper.cs | ||
---|---|---|
75 | 75 |
void ClearFolderStatus(string path); |
76 | 76 |
IEnumerable<FileState> GetChildren(FileState fileState); |
77 | 77 |
void EnsureFileState(string path); |
78 |
|
|
79 |
void CleanupStaleStates(Network.AccountInfo accountInfo, List<ObjectInfo> objectInfos); |
|
80 |
void CleanupOrphanStates(); |
|
78 | 81 |
} |
79 | 82 |
|
80 | 83 |
[ContractClassFor(typeof(IStatusKeeper))] |
... | ... | |
235 | 238 |
{ |
236 | 239 |
|
237 | 240 |
} |
241 |
|
|
242 |
|
|
243 |
public void CleanupStaleStates(Network.AccountInfo accountInfo, List<ObjectInfo> objectInfos) |
|
244 |
{ |
|
245 |
Contract.Requires(accountInfo != null); |
|
246 |
Contract.Requires(objectInfos != null); |
|
247 |
} |
|
248 |
|
|
249 |
|
|
250 |
public void CleanupOrphanStates() |
|
251 |
{ |
|
252 |
} |
|
238 | 253 |
} |
239 | 254 |
} |
Also available in: Unified diff