Now immediatelly downloading new selected folders
[pithos-ms-client] / trunk / Pithos.Core / Agents / PollAgent.cs
index 8a78c23..c0c1d3c 100644 (file)
@@ -628,5 +628,59 @@ namespace Pithos.Core.Agents
             SnapshotDifferencer differencer;\r
             _differencer.Differencers.TryRemove(accountInfo.AccountKey, out differencer);\r
         }\r
+\r
+        public void SetSelectivePaths(AccountInfo accountInfo,Uri[] added, Uri[] removed)\r
+        {\r
+            AbortRemovedPaths(accountInfo,removed);\r
+            DownloadNewPaths(accountInfo,added);\r
+        }\r
+\r
+        private void DownloadNewPaths(AccountInfo accountInfo, Uri[] added)\r
+        {\r
+            var client = new CloudFilesClient(accountInfo);\r
+            foreach (var folderUri in added)\r
+            {\r
+                string account;\r
+                string container;\r
+                var segmentsCount = folderUri.Segments.Length;\r
+                if (segmentsCount < 3)\r
+                    continue;\r
+                if (segmentsCount==3)\r
+                {\r
+                    account = folderUri.Segments[1].TrimEnd('/');\r
+                    container = folderUri.Segments[2].TrimEnd('/');                    \r
+                }\r
+                else\r
+                {\r
+                    account = folderUri.Segments[2].TrimEnd('/');\r
+                    container = folderUri.Segments[3].TrimEnd('/');                    \r
+                }\r
+                IList<ObjectInfo> items;\r
+                if(segmentsCount>3)\r
+                {\r
+                    var folder =String.Join("", folderUri.Segments.Splice(4));\r
+                    items = client.ListObjects(account, container, folder);\r
+                }\r
+                else\r
+                {\r
+                    items = client.ListObjects(account, container);\r
+                }\r
+                var actions=CreatesToActions(accountInfo, items);\r
+                foreach (var action in actions)\r
+                {\r
+                    NetworkAgent.Post(action);    \r
+                }                \r
+            }\r
+\r
+            //Need to get a listing of each of the URLs, then post them to the NetworkAgent\r
+            //CreatesToActions(accountInfo,)\r
+\r
+/*            NetworkAgent.Post();*/\r
+        }\r
+\r
+        private void AbortRemovedPaths(AccountInfo accountInfo, Uri[] removed)\r
+        {\r
+            /*this.NetworkAgent.*/\r
+        }\r
     }\r
 }\r