Revision a308d291 trunk/Pithos.Client.WPF/FileProperties/ConflictResolver.cs
b/trunk/Pithos.Client.WPF/FileProperties/ConflictResolver.cs | ||
---|---|---|
1 | 1 |
using System; |
2 | 2 |
using System.Collections.Generic; |
3 |
using System.ComponentModel.Composition; |
|
3 | 4 |
using System.Linq; |
4 | 5 |
using System.Text; |
6 |
using Caliburn.Micro; |
|
7 |
using Pithos.Core; |
|
8 |
using Pithos.Core.Agents; |
|
9 |
using Pithos.Interfaces; |
|
10 |
using Pithos.Network; |
|
5 | 11 |
|
6 | 12 |
namespace Pithos.Client.WPF.FileProperties |
7 | 13 |
{ |
8 |
public class ConflictResolver:IConflictResolver |
|
14 |
[Export(typeof(IConflictResolver))] |
|
15 |
public class ConflictResolver : IConflictResolver |
|
9 | 16 |
{ |
17 |
[Import] |
|
18 |
public IStatusKeeper StatusAgent { get; set; } |
|
19 |
|
|
20 |
[Import] |
|
21 |
public NetworkAgent NetworkAgent { get; set; } |
|
22 |
|
|
10 | 23 |
public void Resolve(IEnumerable<ConflictFile> conflicts) |
11 | 24 |
{ |
12 | 25 |
KeepServer(conflicts.Where(c => c.Action == ConflictAction.KeepServer)); |
... | ... | |
21 | 34 |
private void ClearLocal(IEnumerable<ConflictFile> conflicts) |
22 | 35 |
{ |
23 | 36 |
//This can be done simply by changing the local Filestate status to normal |
37 |
conflicts.Apply(clear => |
|
38 |
StatusAgent.SetFileState(clear.FilePath, FileStatus.Unchanged, FileOverlayStatus.Normal, "")); |
|
39 |
|
|
24 | 40 |
} |
25 | 41 |
|
26 | 42 |
|
... | ... | |
30 | 46 |
{ |
31 | 47 |
//This can be done either by scheduling the appropriate action, ignoring the hash |
32 | 48 |
//Or directly downloading the file. |
49 |
|
|
33 | 50 |
|
51 |
foreach (var conflict in conflicts) |
|
52 |
{ |
|
53 |
//a.Post(new CloudDownloadAction()); |
|
54 |
PithosMonitor monitor; |
|
55 |
/* |
|
56 |
var account = monitor.Account; |
|
57 |
var oi=monitor.GetObjectInfo(conflict.FilePath); |
|
58 |
NetworkAgent.Post(new CloudDownloadAction(account,oi,"Resolver")); |
|
59 |
*/ |
|
60 |
} |
|
61 |
|
|
62 |
|
|
34 | 63 |
} |
35 | 64 |
|
36 | 65 |
//Keeping the server version means that we need to |
... | ... | |
39 | 68 |
{ |
40 | 69 |
//This can be done either by scheduling the appropriate action, ignoring the hash |
41 | 70 |
//Or directly uploading the file. |
42 |
|
|
71 |
foreach (var conflict in conflicts) |
|
72 |
{ |
|
73 |
var info = FileInfoExtensions.FromPath(conflict.FilePath); |
|
74 |
var state=StatusAgent.GetStateByFilePath(conflict.FilePath); |
|
75 |
PithosMonitor monitor; |
|
76 |
|
|
77 |
/* |
|
78 |
var pair=(from monitor in Monitors |
|
79 |
where conflict.FilePath.StartsWith(monitor.Value.RootPath, StringComparison.InvariantCultureIgnoreCase) |
|
80 |
select monitor).FirstOrDefault(); |
|
81 |
var accountMonitor = pair.Value; |
|
82 |
*/ |
|
83 |
/* |
|
84 |
var account = monitor.Account; |
|
85 |
//var oi=monitor.GetObjectInfo(conflict.FilePath); |
|
86 |
NetworkAgent.Post(new CloudUploadAction(account,info,state,account.BlockSize,account.BlockHash,"Resolver")); |
|
87 |
//NetworkAgent.Post(new CloudUploadAction(,info,conflict.FileState,NetworkAgent.)); |
|
88 |
*/ |
|
89 |
} |
|
43 | 90 |
} |
44 | 91 |
|
45 | 92 |
//Keeping both versions means that we need to copy one of them |
Also available in: Unified diff