Fixes for v.0.7.20401
authorpkanavos <pkanavos@gmail.com>
Mon, 2 Apr 2012 20:08:21 +0000 (23:08 +0300)
committerpkanavos <pkanavos@gmail.com>
Mon, 2 Apr 2012 20:08:21 +0000 (23:08 +0300)
19 files changed:
trunk/Pithos.Client.WPF/App.xaml.cs
trunk/Pithos.Client.WPF/FileProperties/ContainerPropertiesViewModel.cs
trunk/Pithos.Client.WPF/FileProperties/FilePropertiesViewModel.cs
trunk/Pithos.Client.WPF/Preferences/AccountViewModel.cs
trunk/Pithos.Client.WPF/Preferences/AddAccountViewModel.cs
trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs
trunk/Pithos.Client.WPF/Properties/AssemblyInfo.cs
trunk/Pithos.Client.WPF/SelectiveSynch/SelectiveSynchViewModel.cs
trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs
trunk/Pithos.Core/Agents/PollAgent.cs
trunk/Pithos.Core/PithosMonitor.cs
trunk/Pithos.Installer/rnotes.0.7.20401.html [new file with mode: 0644]
trunk/Pithos.Installer/versioninfo.xml
trunk/Pithos.Interfaces/AccountSettings.cs
trunk/Pithos.Interfaces/ObjectInfo.cs
trunk/Pithos.Network/AccountInfo.cs
trunk/Pithos.Network/CloudFilesClient.cs
trunk/Pithos.Network/ContainerInfo.cs
trunk/Pithos.Network/WebExtensions.cs

index 86e35ce..6768577 100644 (file)
@@ -208,7 +208,7 @@ namespace Pithos.Client.WPF
                 WPF.Properties.Resources.We_Apologize, 
                 WPF.Properties.Resources.Please_Submit_Error);
             ShowMessages("Oops!",message, messages);
-            e.SetObserved();
+            e.SetObserved();            
         }
 
         private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
index 0683244..1424a16 100644 (file)
@@ -401,7 +401,7 @@ namespace Pithos.Client.WPF.FileProperties
             if (TagsChanged)
             {
                 Container.Tags = this.Tags.ToDictionary(tag => tag.Name, tag => tag.Value);
-                var monitor = Shell.Monitors[Container.Account];
+                var monitor = Shell.Monitors[Container.AccountKey];
                 monitor.CloudClient.UpdateMetadata(Container);
             }
 
index f4a26f4..e663901 100644 (file)
@@ -452,8 +452,8 @@ namespace Pithos.Client.WPF
             PithosFile.ContentEncoding = ContentEncoding;
             PithosFile.Manifest = Manifest;
             PithosFile.IsPublic = IsPublic;
-
-            var monitor = Shell.Monitors[PithosFile.Account];
+            
+            var monitor = Shell.Monitors[PithosFile.AccountKey];
             monitor.CloudClient.UpdateMetadata(PithosFile);
 
 
index c7d3e50..212bef0 100644 (file)
@@ -39,6 +39,8 @@
  * -----------------------------------------------------------------------
  */
 #endregion
+
+using System;
 using Caliburn.Micro;
 using Pithos.Interfaces;
 
@@ -62,6 +64,10 @@ namespace Pithos.Client.WPF.Preferences
             _account = account;            
         }
 
+        public Uri AccountKey
+        {
+            get { return new Uri(new Uri(_account.ServerUrl) , _account.AccountName); }
+        }
 
         public string AccountName
         {
index 4ae2a98..884ee7b 100644 (file)
@@ -214,6 +214,7 @@ namespace Pithos.Client.WPF.Preferences
                 Token = credentials.Password;
 
                 IsConfirmed = true;
+
             }
             catch (PithosException exc)
             {
@@ -233,6 +234,9 @@ namespace Pithos.Client.WPF.Preferences
                 ((Window) GetView()).Activate();
             }
 
+            if (IsConfirmed)
+                TaskEx.Run(TestAccount);
+
         }
 
         public AddAccountViewModel()
index 39707cb..358ab44 100644 (file)
@@ -72,7 +72,7 @@ namespace Pithos.Client.WPF.Preferences
     /// The class is a single ViewModel for all Preferences tabs. It can be broken in separate
     /// ViewModels, one for each tab.
     /// </remarks>
-    [Export]
+    [Export, PartCreationPolicy(CreationPolicy.Shared)]
     public class PreferencesViewModel : Screen
     {
         private readonly IEventAggregator _events;
@@ -219,7 +219,7 @@ namespace Pithos.Client.WPF.Preferences
 
         public void SelectiveSyncFolders()
         {
-            var monitor = Shell.Monitors[CurrentAccount.AccountName];
+            var monitor = Shell.Monitors[CurrentAccount.AccountKey];
             
 
             var model = new SelectiveSynchViewModel(monitor,_events,CurrentAccount.Account);
@@ -318,7 +318,7 @@ namespace Pithos.Client.WPF.Preferences
             {
                 foreach (var account in _accountsToRemove)
                 {
-                    Shell.RemoveMonitor(account.AccountName);
+                    Shell.RemoveMonitor(account.ServerUrl, account.AccountName);
                     Shell.RemoveAccountFromDatabase(account);
                 }
 
@@ -589,7 +589,7 @@ namespace Pithos.Client.WPF.Preferences
             var newPath= dlg.SelectedPath;                
             //Find the account's monitor and stop it
             PithosMonitor monitor;
-            if (Shell.Monitors.TryGetValue(CurrentAccount.AccountName, out monitor))
+            if (Shell.Monitors.TryGetValue(CurrentAccount.AccountKey, out monitor))
             {
                 monitor.Stop();
 
index 3115c50..5b1b657 100644 (file)
@@ -93,5 +93,5 @@ using System.Windows;
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.7.20319.0")]
-[assembly: AssemblyFileVersionAttribute("0.7.20319.0")]
+[assembly: AssemblyVersion("0.7.20401.0")]
+[assembly: AssemblyFileVersionAttribute("0.7.20401.0")]
index 70da404..50a19cb 100644 (file)
@@ -56,16 +56,6 @@ namespace Pithos.Client.WPF.SelectiveSynch
         private const string DirectoryType = "application/directory";
         private readonly IEventAggregator _events ;
 
-        private string _title;
-        public string Title
-        {
-            get { return _title; }
-            set
-            {
-                _title = value;
-                NotifyOfPropertyChange(() => Title);
-            }
-        }
 
         public AccountSettings Account { get; set; }
 
@@ -98,7 +88,7 @@ namespace Pithos.Client.WPF.SelectiveSynch
         {
             Account = account;
             AccountName = account.AccountName;
-            Title = account.AccountName;
+            DisplayName = account.AccountName;
             _monitor = monitor;
             _events = events;
             TaskEx.Run(LoadRootNode);
@@ -123,10 +113,12 @@ namespace Pithos.Client.WPF.SelectiveSynch
                              select new DirectoryRecord
                              {
                                 DisplayName=account.name,
+                                Uri=new Uri(client.StorageUrl,"../"+ account.name),
                                 Directories=(from container in client.ListContainers(account.name)
                                             select new DirectoryRecord
                                                         {
                                                             DisplayName=container.Name,
+                                                            Uri = new Uri(client.StorageUrl, "../" + account.name + "/" + container.Name),
                                                             Directories=(from folder in client.ListObjects(account.name,container.Name,"")
                                                                         where folder.Content_Type==DirectoryType
                                                                         select new DirectoryRecord{DisplayName=folder.Name,ObjectInfo=folder}).ToList()
index 96a650c..69fae86 100644 (file)
@@ -97,7 +97,7 @@ namespace Pithos.Client.WPF {
                public PithosSettings Settings { get; private set; }
 
 
-               private readonly ConcurrentDictionary<string, PithosMonitor> _monitors = new ConcurrentDictionary<string, PithosMonitor>();
+               private readonly ConcurrentDictionary<Uri, PithosMonitor> _monitors = new ConcurrentDictionary<Uri, PithosMonitor>();
                ///<summary>
                /// Dictionary of account monitors, keyed by account
                ///</summary>
@@ -107,7 +107,7 @@ namespace Pithos.Client.WPF {
                ///</remarks>
                // TODO: Does the Shell REALLY need access to the monitors? Could we achieve the same results with a better design?
                // TODO: The monitors should be internal to Pithos.Core, even though exposing them makes coding of the Object and Container windows easier
-               public ConcurrentDictionary<string, PithosMonitor> Monitors
+               public ConcurrentDictionary<Uri, PithosMonitor> Monitors
                {
                        get { return _monitors; }
                }
@@ -262,17 +262,15 @@ namespace Pithos.Client.WPF {
                {
                        try
                        {
+                if (Settings.IgnoreCertificateErrors)
+                {
+                    ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
+                }
+                    
                                var accounts = Settings.Accounts.Select(MonitorAccount);
                                await TaskEx.WhenAll(accounts);
                                _statusService = StatusService.Start();
 
-/*
-                               foreach (var account in Settings.Accounts)
-                               {
-                                       await MonitorAccount(account);
-                               }
-*/
-                               
                        }
                        catch (AggregateException exc)
                        {
@@ -302,7 +300,7 @@ namespace Pithos.Client.WPF {
                                PithosMonitor monitor;
                                var accountName = account.AccountName;
 
-                               if (_monitors.TryGetValue(accountName, out monitor))
+                               if (Monitors.TryGetValue(account.AccountKey, out monitor))
                                {
                                        //If the account is active
                     if (account.IsActive)
@@ -319,7 +317,7 @@ namespace Pithos.Client.WPF {
                     {
                         //If the account is inactive
                         //Stop and remove the monitor
-                        RemoveMonitor(accountName);
+                        RemoveMonitor(account.ServerUrl,accountName);
                     }
                                        return;
                                }
@@ -338,7 +336,7 @@ namespace Pithos.Client.WPF {
 
                                monitor.AuthenticationUrl = account.ServerUrl;
 
-                               _monitors[accountName] = monitor;
+                               Monitors[account.AccountKey] = monitor;
 
                                if (account.IsActive)
                                {
@@ -615,9 +613,8 @@ namespace Pithos.Client.WPF {
                {
                        if (currentInfo==null)
                                throw new ArgumentNullException("currentInfo");
-                       Contract.EndContractBlock();
-
-                       var monitor = Monitors[currentInfo.Account];
+                       Contract.EndContractBlock();                
+            var monitor = Monitors[currentInfo.AccountKey];
                        var newInfo=monitor.CloudClient.GetObjectInfo(currentInfo.Account, currentInfo.Container, currentInfo.Name);
                        return newInfo;
                }
@@ -628,7 +625,7 @@ namespace Pithos.Client.WPF {
                                throw new ArgumentNullException("container");
                        Contract.EndContractBlock();
 
-                       var monitor = Monitors[container.Account];
+                       var monitor = Monitors[container.AccountKey];
                        var newInfo = monitor.CloudClient.GetContainerInfo(container.Account, container.Name);
                        return newInfo;
                }
@@ -873,20 +870,21 @@ namespace Pithos.Client.WPF {
                }
 
 
-               public void RemoveMonitor(string accountName)
+               public void RemoveMonitor(string serverUrl,string accountName)
                {
                        if (String.IsNullOrWhiteSpace(accountName))
                                return;
 
-                       var accountInfo=_accounts.FirstOrDefault(account => account.UserName == accountName);
+                       var accountInfo=_accounts.FirstOrDefault(account => account.UserName == accountName && account.StorageUri.ToString().StartsWith(serverUrl));
             if (accountInfo != null)
             {
                 _accounts.TryRemove(accountInfo);
                 _pollAgent.RemoveAccount(accountInfo);
             }
 
+            var accountKey = new Uri(new Uri(serverUrl),accountName);
                    PithosMonitor monitor;
-                       if (Monitors.TryRemove(accountName, out monitor))
+                       if (Monitors.TryRemove(accountKey, out monitor))
                        {
                                monitor.Stop();
                 //TODO: Also remove any pending actions for this account
@@ -926,10 +924,9 @@ namespace Pithos.Client.WPF {
                #region Event Handlers
                
                public void Handle(SelectiveSynchChanges message)
-               {
-                       var accountName = message.Account.AccountName;
+               {            
                        PithosMonitor monitor;
-                       if (_monitors.TryGetValue(accountName, out monitor))
+                       if (Monitors.TryGetValue(message.Account.AccountKey, out monitor))
                        {
                                monitor.SetSelectivePaths(message.Uris,message.Added,message.Removed);
 
index 25474b1..3a4a2bf 100644 (file)
@@ -270,18 +270,21 @@ namespace Pithos.Core.Agents
 \r
                         var differencer = _differencer.PostSnapshot(accountInfo, cleanRemotes);\r
 \r
-                        ProcessDeletedFiles(accountInfo, differencer.Deleted.FilterDirectlyBelow(SelectiveUris));\r
+                        var filterUris = SelectiveUris[accountInfo.AccountKey];\r
+\r
+                        ProcessDeletedFiles(accountInfo, differencer.Deleted.FilterDirectlyBelow(filterUris));\r
 \r
                         // @@@ NEED To add previous state here as well, To compare with previous hash\r
 \r
                         \r
 \r
                         //Create a list of actions from the remote files\r
-                        var allActions = MovesToActions(accountInfo,differencer.Moved.FilterDirectlyBelow(SelectiveUris))\r
+                        \r
+                        var allActions = MovesToActions(accountInfo,differencer.Moved.FilterDirectlyBelow(filterUris))\r
                                         .Union(\r
-                                        ChangesToActions(accountInfo, differencer.Changed.FilterDirectlyBelow(SelectiveUris)))\r
+                                        ChangesToActions(accountInfo, differencer.Changed.FilterDirectlyBelow(filterUris)))\r
                                         .Union(\r
-                                        CreatesToActions(accountInfo, differencer.Created.FilterDirectlyBelow(SelectiveUris)));\r
+                                        CreatesToActions(accountInfo, differencer.Created.FilterDirectlyBelow(filterUris)));\r
 \r
                         //And remove those that are already being processed by the agent\r
                         var distinctActions = allActions\r
@@ -347,7 +350,7 @@ namespace Pithos.Core.Agents
         }\r
 \r
         readonly AccountsDifferencer _differencer = new AccountsDifferencer();\r
-        private List<Uri> _selectiveUris=new List<Uri>();\r
+        private Dictionary<Uri, List<Uri>> _selectiveUris = new Dictionary<Uri, List<Uri>>();\r
 \r
         /// <summary>\r
         /// Deletes local files that are not found in the list of cloud files\r
@@ -597,12 +600,12 @@ namespace Pithos.Core.Agents
             }\r
         }\r
 \r
-        public void SetSyncUris(Uri[] uris)\r
+        public void SetSyncUris(Uri accountKey, Uri[] uris)\r
         {            \r
-            SelectiveUris=uris.ToList();\r
+            SelectiveUris[accountKey]=uris.ToList();\r
         }\r
 \r
-        protected List<Uri> SelectiveUris\r
+        protected Dictionary<Uri,List<Uri>> SelectiveUris\r
         {\r
             get { return _selectiveUris;}\r
             set { _selectiveUris = value; }\r
index ce0acd1..122c4fb 100644 (file)
@@ -220,7 +220,7 @@ namespace Pithos.Core
             StatusKeeper.StartProcessing(_cancellationSource.Token);
             IndexLocalFiles();
             //Extract the URIs from the string collection
-            var settings = Settings.Accounts.First(s => s.AccountName == _accountInfo.UserName);
+            var settings = Settings.Accounts.First(s => s.AccountKey == _accountInfo.AccountKey );
             var selectiveUrls=settings.SelectiveFolders.Cast<string>().Select(url => new Uri(url)).ToArray();
 
             SetSelectivePaths(selectiveUrls,null,null);
@@ -432,7 +432,7 @@ namespace Pithos.Core
             var selectivePaths = UrisToFilePaths(uris);
             
             FileAgent.SelectivePaths=selectivePaths;
-            PollAgent.SetSyncUris(uris);
+            PollAgent.SetSyncUris(_accountInfo.AccountKey,uris);
             
             var removedPaths = UrisToFilePaths(removed);
             UnversionSelectivePaths(removedPaths);
diff --git a/trunk/Pithos.Installer/rnotes.0.7.20401.html b/trunk/Pithos.Installer/rnotes.0.7.20401.html
new file mode 100644 (file)
index 0000000..ae2e7a6
--- /dev/null
@@ -0,0 +1,12 @@
+<html>
+<body>
+<h2>Pithos MS Client v. 0.7.20401</h2>
+Release Date: Apr 01, 2012, 23:00
+<br/>
+Includes:
+<br/>
+<ul>
+<li> Fixes for maximum hashmap size</li>
+</ul>
+</body>
+</html>
\ No newline at end of file
index 4e304a7..eaac099 100644 (file)
@@ -5,7 +5,18 @@
                <title>Pithos MS Client</title>      \r
                <link>https://code.grnet.gr/projects/pithos-ms-client/repository/revisions/master/changes/trunk/Pithos.Installer/versioninfo.xml</link>     \r
                <description></description>      \r
-               <language>en</language>                 \r
+               <language>en</language>                         \r
+               <item>            \r
+                       <title>Version 0.7.20401</title>\r
+                       <sparkle:releaseNotesLink>https://code.grnet.gr/projects/pithos-ms-client/repository/revisions/master/raw/trunk/Pithos.Installer/rnotes.0.7.20401.html</sparkle:releaseNotesLink>\r
+                       <pubDate>Fri, 02 Apr 2012 23:00:00 +0200</pubDate>\r
+                       <enclosure \r
+                               url="https://code.grnet.gr/attachments/download/1051/PithosPlus_Setupv0.7.20319.0.exe"\r
+                               length="4947759" \r
+                               type="application/octet-stream"\r
+                               sparkle:version="0.7.20401" \r
+                       />\r
+               </item>\r
                <item>            \r
                        <title>Version 0.7.20319</title>\r
                        <sparkle:releaseNotesLink>https://code.grnet.gr/projects/pithos-ms-client/repository/revisions/master/raw/trunk/Pithos.Installer/rnotes.0.7.20319.html</sparkle:releaseNotesLink>\r
index 33ec9e5..a0bf8fe 100644 (file)
@@ -53,7 +53,12 @@ namespace Pithos.Interfaces
         
         public string AccountName { get; set; }
 
-        
+        public Uri AccountKey
+        {
+            get { return new Uri(new Uri(ServerUrl), AccountName); }
+        }
+
+
         public string ApiKey { get; set; }
 
         public bool IsActive { get; set; }
@@ -64,12 +69,7 @@ namespace Pithos.Interfaces
 
         private StringCollection _selectiveFolders = new StringCollection();
 
-        private bool _isExpired;
-        public bool IsExpired
-        {
-            get { return _isExpired; }
-            set { _isExpired = value; }
-        }
+        public bool IsExpired { get; set; }
 
         public StringCollection SelectiveFolders
         {
index 54f68ad..cd2a6a3 100644 (file)
@@ -353,6 +353,11 @@ namespace Pithos.Interfaces
             }
         }
 
+        public Uri AccountKey
+        {
+            get { return new Uri(StorageUri,"../" + Account); }
+        }
+
         public ObjectInfo SetPrevious(ObjectInfo previous)
         {            
             Previous = previous;
index 2f40246..63195f4 100644 (file)
@@ -49,6 +49,11 @@ namespace Pithos.Network
         public string UserName { get; set; }
         public string Token { get; set; }
         public Uri StorageUri { get; set; }
+
+        public Uri AccountKey
+        {
+            get{return new Uri(StorageUri,"../" + UserName);}
+        }
         
         private string _accountPath;
         public string AccountPath
index e11b4d6..497bc15 100644 (file)
@@ -242,7 +242,7 @@ namespace Pithos.Network
             }
 
             Log.InfoFormat("[AUTHENTICATE] End for {0}", UserName);
-            
+            Debug.Assert(_baseClient!=null);
 
             return new AccountInfo {StorageUri = StorageUrl, Token = Token, UserName = UserName,Groups=groups};            
 
@@ -872,6 +872,7 @@ namespace Pithos.Network
                                                 {
                                                     Account=account,
                                                     Name = container,
+                                                    StorageUrl=this.StorageUrl.ToString(),
                                                     Count =
                                                         long.Parse(client.GetHeaderValue("X-Container-Object-Count")),
                                                     Bytes = long.Parse(client.GetHeaderValue("X-Container-Bytes-Used")),
@@ -1061,7 +1062,7 @@ namespace Pithos.Network
                     {
                         //In case of 409 the missing parts will be in the response content                        
                         using (var stream = response.GetResponseStream())
-                        using(var reader=stream.GetLoggedReader(Log,response.ContentLength))
+                        using(var reader=stream.GetLoggedReader(Log))
                         {
                             //We used to have to cleanup the content before returning it because it contains
                             //error content after the list of hashes
index 718b827..6e0295c 100644 (file)
@@ -48,6 +48,7 @@ namespace Pithos.Network
     {
         public string Account { get; set; }
         public string Name { get; set; }
+        public string StorageUrl { get; set; }
         public long Count { get; set; }
         public long Bytes { get; set; }
         public string BlockHash { get; set; }
@@ -58,6 +59,12 @@ namespace Pithos.Network
         public Dictionary<string, string> Tags { get; set; }
         public Dictionary<string, string> Policies { get; set; }
 
+        public Uri AccountKey
+        {
+            get { return new Uri(new Uri(StorageUrl), "../" + Account); }
+        }
+
+
         public static ContainerInfo Empty=new ContainerInfo();
 
         public ContainerInfo()
index 66b8e6d..6676d65 100644 (file)
@@ -36,7 +36,7 @@ namespace Pithos.Network
             }
         }
 
-        public static TextReader GetLoggedReader(this Stream stream, ILog log, long contentLength)
+        public static TextReader GetLoggedReader(this Stream stream, ILog log)
         {
             var reader = new StreamReader(stream);
             if (!log.IsDebugEnabled)
@@ -44,9 +44,7 @@ namespace Pithos.Network
             
             using (reader)
             {
-                var buffer=new char[contentLength];
-                var read=reader.Read(buffer, 0, (int)contentLength);
-                var body = new string(buffer,0,read); //reader.ReadToEnd();
+                var body = reader.ReadToEnd();
                 log.DebugFormat("JSON response: {0}", body);
                 return new StringReader(body);
             }