X-Git-Url: https://code.grnet.gr/git/pithos-ms-client/blobdiff_plain/ec91de7948ede960ebee47bed497ecaff4d68fb4..1c9bbe2cec2d6f9187700c16b0182e8d8d86ca3e:/trunk/Pithos.Client.WPF/FileProperties/ConflictResolver.cs diff --git a/trunk/Pithos.Client.WPF/FileProperties/ConflictResolver.cs b/trunk/Pithos.Client.WPF/FileProperties/ConflictResolver.cs new file mode 100644 index 0000000..010e956 --- /dev/null +++ b/trunk/Pithos.Client.WPF/FileProperties/ConflictResolver.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Pithos.Client.WPF.FileProperties +{ + public class ConflictResolver:IConflictResolver + { + public void Resolve(IEnumerable conflicts) + { + KeepServer(conflicts.Where(c => c.Action == ConflictAction.KeepServer)); + KeepLocal(conflicts.Where(c => c.Action == ConflictAction.KeepLocal)); + KeepBoth(conflicts.Where(c => c.Action == ConflictAction.KeepBoth)); + ClearLocal(conflicts.Where(c => c.Action == ConflictAction.ClearLocal)); + } + + + //Clearing the local state means that we clear the conflict state of the local file. + //This is needed to clear wrong conflicts + private void ClearLocal(IEnumerable conflicts) + { + //This can be done simply by changing the local Filestate status to normal + } + + + //Keeping the server version means that we need to + //download the server's version of the file. + private void KeepServer(IEnumerable conflicts) + { + //This can be done either by scheduling the appropriate action, ignoring the hash + //Or directly downloading the file. + + } + + //Keeping the server version means that we need to + //upload the local version of the file to the server + private void KeepLocal(IEnumerable conflicts) + { + //This can be done either by scheduling the appropriate action, ignoring the hash + //Or directly uploading the file. + + } + + //Keeping both versions means that we need to copy one of them + //somewhere and keep the other + private void KeepBoth(IEnumerable conflicts) + { + //We can copy the rename the local file to another name and download the server file + //Or rename the server file and upload the local file + + //Downloading the server file is probably much faster with ADSL connections + + //We could probably use the local file as a source of blocks to download fewer data, + //We create a hashmap of the local file, download the differences from the server + //and merge common and changed blocks to create the new file. + } + } +}