--- /dev/null
+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<ConflictFile> 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<ConflictFile> 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<ConflictFile> 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<ConflictFile> 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<ConflictFile> 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.
+ }
+ }
+}
\r
var localFolders = SelectiveExtensions.LocalFolders(AccountName, Account.RootPath,client.StorageUrl.AbsoluteUri);\r
\r
-<<<<<<< HEAD
AppendToTree(localFolders, rootItem);\r
-=======
- foreach (var folder in localFolders)\r
- {\r
- //If this folder is not included in the server folders\r
- if (!rootItem.Directories.Any(dir => dir.Uri == folder.Uri))\r
- {\r
- //we need to add it\r
- //Find the best parent\r
-\r
- //One way to do this, is to break the the Uri to its parts\r
- //and try to find a parent using progressively fewer parts\r
- var parts = folder.Uri.AbsoluteUri.Split('/');\r
- for (var i = parts.Length - 1; i > 0; i--)\r
- {\r
- var parentUrl = String.Join("/",parts.Splice(0, i));\r
- var parentUri = new Uri(parentUrl);\r
-\r
- var parent = rootItem.Directories.FirstOrDefault(dir => dir.Uri == parentUri);\r
- if (parent != null)\r
- {\r
- parent.Directories.Add(folder);\r
- break;\r
- }\r
- }\r
- }\r
- }\r
->>>>>>> 2313b22d680c12277646ac923c3954b91f25d5f6
\r
//For each local folder that doesn't exist in the server nodes \r
//find the best matching parent and add the folder below it.\r