Fixed handling for Content_Type "application/folder" in SelectiveSync and other locations
authorpkanavos <pkanavos@gmail.com>
Tue, 24 Apr 2012 19:22:41 +0000 (22:22 +0300)
committerpkanavos <pkanavos@gmail.com>
Tue, 24 Apr 2012 19:22:41 +0000 (22:22 +0300)
trunk/Pithos.Client.WPF/Diagnostics/log4netForwarder.cs
trunk/Pithos.Client.WPF/Properties/AssemblyInfo.cs
trunk/Pithos.Client.WPF/SelectiveSynch/SelectiveSynchViewModel.cs
trunk/Pithos.Client.WPF/app.config
trunk/Pithos.Core/Agents/NetworkAgent.cs
trunk/Pithos.Core/Agents/PollAgent.cs
trunk/Pithos.Core/LocalFileComparer.cs
trunk/Pithos.Network.Test/CloudFilesClientTest.cs

index a706898..670c975 100644 (file)
@@ -93,9 +93,6 @@ namespace Pithos.Client.WPF.Diagnostics
         {
             try
             {
-                var stack = new StackTrace();
-                var type = stack.GetFrame(0).GetMethod().DeclaringType;
-
                 var log = LogManager.GetLogger(source);
                 var level = GetLevel(eventType);
                 TaskEx.Run(()=>log.Logger.Log(GetType(), level, message, null));
index 496f4a6..6283711 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.20424.0")]
-[assembly: AssemblyFileVersionAttribute("0.7.20424.0")]
+[assembly: AssemblyVersion("0.7.20424.1")]
+[assembly: AssemblyFileVersionAttribute("0.7.20424.1")]
index dd1cc21..cae3de2 100644 (file)
@@ -53,8 +53,7 @@ using Pithos.Interfaces;
 namespace Pithos.Client.WPF.SelectiveSynch
 {
     class SelectiveSynchViewModel:Screen
-    {
-        private const string DirectoryType = "application/directory";
+    {        
         private readonly IEventAggregator _events ;
 
 
@@ -105,7 +104,7 @@ namespace Pithos.Client.WPF.SelectiveSynch
                                       DisplayName = container.Name,
                                       Uri=new Uri(client.StorageUrl,String.Format(@"{0}/{1}",Account.AccountName, container.Name)),
                                       Directories = (from dir in client.ListObjects(_monitor.UserName, container.Name)                                                     
-                                                     where dir.Content_Type == DirectoryType
+                                                     where dir.IsDirectory
                                                      select dir).ToTree()
                                   };
             var ownFolders = dirs.ToList();
@@ -121,7 +120,7 @@ namespace Pithos.Client.WPF.SelectiveSynch
                                                             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
+                                                                        where folder.IsDirectory
                                                                         select folder).ToTree()
                                                         }).ToList()
                              };                                                          
index de2b4a7..30b6f8d 100644 (file)
@@ -28,7 +28,7 @@
 
 <system.diagnostics >
     <sources >
-      <source name="System.Net"  switchValue="Verbose" tracemode="protocolonly" maxdatasize="65536" >
+      <source name="System.Net"  switchValue="Information" tracemode="protocolonly" maxdatasize="65536" >
         <listeners>
           <add name="ms" type="Pithos.Client.WPF.Diagnostics.Log4NetForwarder,PithosPlus"/>
         </listeners>
index 0bdddd1..6a54c93 100644 (file)
@@ -331,10 +331,16 @@ namespace Pithos.Core.Agents
                 var downloadPath = action.LocalFile.GetProperCapitalization();
 
                 var cloudHash = cloudFile.Hash.ToLower();
-                var previousCloudHash = cloudFile.PreviousHash.ToLower();
+                var previousCloudHash = cloudFile.PreviousHash == null?null: cloudFile.PreviousHash.ToLower();
                 var localHash = action.TreeHash.Value.TopHash.ToHashString();// LocalHash.Value.ToLower();
                 //var topHash = action.TopHash.Value.ToLower();
 
+                if(cloudFile.IsDirectory && action.LocalFile is DirectoryInfo)
+                {
+                    Log.InfoFormat("Skipping folder {0} , exists in server", downloadPath);
+                    return;
+                }
+
                 //At this point we know that an object has changed on the server and that a local
                 //file already exists. We need to decide whether the file has only changed on 
                 //the server or there is a conflicting change on the client.
index 99f8e81..3483559 100644 (file)
@@ -469,7 +469,7 @@ namespace Pithos.Core.Agents
                 {\r
                     var localFile = fileAgent.GetFileSystemInfo(relativePath);\r
                     //We don't need to sync directories\r
-                    if (objectInfo.Content_Type == @"application/directory" && localFile is DirectoryInfo)\r
+                    if (objectInfo.IsDirectory && localFile is DirectoryInfo)\r
                         continue;\r
                     using (new SessionScope(FlushAction.Never))\r
                     {\r
index 5a13de8..2006f3f 100644 (file)
@@ -24,7 +24,7 @@ namespace Pithos.Core
                 if (!x.CloudFile.Hash.Equals(y.CloudFile.Hash))
                     return false;
                 //All directories have the same hash. Compare them using their names instead
-                if (x.CloudFile.Content_Type == y.CloudFile.Content_Type && x.CloudFile.Content_Type == "application/directory")
+                if (x.CloudFile.Content_Type == y.CloudFile.Content_Type && x.CloudFile.IsDirectory)
                 {
                     return (x.CloudFile.Name == y.CloudFile.Name);
                 }
@@ -44,7 +44,7 @@ namespace Pithos.Core
             if (obj.CloudFile != null)
             {
                 //All directories have the same hash code. Use their name's hash code instead
-                hash2 = obj.CloudFile.Content_Type == "application/directory" 
+                hash2 = obj.CloudFile.IsDirectory 
                             ? obj.CloudFile.Name.GetHashCode() 
                             : (obj.CloudFile.Hash ?? obj.CloudFile.Name ?? "").GetHashCode();
             }
index aa06f08..9cb7e1d 100644 (file)
@@ -71,9 +71,9 @@ namespace Pithos.Network.Test
 
 
             var pithos=containers.First(c => c.Name == "pithos");
-            var directories=client.ListObjects(account,"pithos","").Where(info=>info.Content_Type=="application/directory");
+            var directories=client.ListObjects(account,"pithos","").Where(info=>info.IsDirectory);
             Assert.That(directories,!Is.Empty);
-            Assert.IsTrue(directories.All(info=>info.Content_Type=="application/directory"));
+            Assert.IsTrue(directories.All(info=>info.IsDirectory));
         }