Modified FileSystemWatcherAdapter.cs to raise create events for all child objects...
authorPanagiotis Kanavos <pkanavos@gmail.com>
Thu, 1 Mar 2012 15:49:30 +0000 (17:49 +0200)
committerPanagiotis Kanavos <pkanavos@gmail.com>
Thu, 1 Mar 2012 15:49:30 +0000 (17:49 +0200)
Fixes #2120

trunk/Pithos.Client.WPF/Properties/AssemblyInfo.cs
trunk/Pithos.Core.Test/Pithos.Core.Test.csproj
trunk/Pithos.Core/Agents/FileSystemWatcherAdapter.cs
trunk/Pithos.Setup.x64/Pithos.Setup.x64.vdproj
trunk/Pithos.Setup.x86/Pithos.Setup.x86.vdproj

index ebdd902..3227f4b 100644 (file)
@@ -94,4 +94,4 @@ using System.Windows;
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("0.7.0.0")]
-[assembly: AssemblyFileVersionAttribute("0.7.20301.2122")]
+[assembly: AssemblyFileVersionAttribute("0.7.20302.2120")]
index 867c2fd..cb9bf18 100644 (file)
   <ItemGroup>
     <Compile Include="EnumerableExtensionsTest.cs" />
     <Compile Include="ExtensionTests.cs" />
+    <Compile Include="FileSystemWatcherAdapterTest.cs" />
     <Compile Include="NetworkAgentTest.cs" />
     <Compile Include="PithosWorkflowTest.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
index 54592df..0dd40cd 100644 (file)
@@ -47,12 +47,9 @@ using Pithos.Interfaces;
 namespace Pithos.Core.Agents\r
 {\r
     using System;\r
-    using System.Collections.Generic;\r
-    using System.Linq;\r
-    using System.Text;\r
 \r
     /// <summary>\r
-    /// TODO: Update summary.\r
+    /// Wraps a FileSystemWatcher and raises Move and child object events \r
     /// </summary>\r
     public class FileSystemWatcherAdapter\r
     {\r
@@ -76,12 +73,7 @@ namespace Pithos.Core.Agents
         }\r
 \r
         private string _cachedDeletedFullPath;\r
-        private const int PropagateDelay = 10;        \r
-\r
-        private static void OnTimeout(object state)\r
-        {\r
-            throw new NotImplementedException();\r
-        }\r
+        private const int PropagateDelay = 10;\r
 \r
         private void OnDeleted(object sender, FileSystemEventArgs e)\r
         {\r
@@ -115,7 +107,7 @@ namespace Pithos.Core.Agents
             TaskEx.Delay(PropagateDelay).ContinueWith(t =>\r
                                                            {\r
                                                                var myPath = e.FullPath;\r
-                                                               if (this._cachedDeletedFullPath==myPath)\r
+                                                               if (_cachedDeletedFullPath==myPath)\r
                                                                     PropagateCachedDeleted(sender);\r
                                                            });\r
         }\r
@@ -162,8 +154,13 @@ namespace Pithos.Core.Agents
                 PropagateCachedDeleted(sender);\r
                 //and propagate the actual event\r
                 var actualEvent = e.ChangeType == WatcherChangeTypes.Created ? Created : Changed;\r
+\r
                 if (actualEvent != null)\r
+                {\r
                     actualEvent(sender, e);\r
+                    //For Folders, raise Created events for all children\r
+                    RaiseCreatedForChildren(sender,e);\r
+                }\r
             }\r
             finally\r
             {\r
@@ -173,6 +170,24 @@ namespace Pithos.Core.Agents
 \r
         }\r
 \r
+        private void RaiseCreatedForChildren(object sender, FileSystemEventArgs e)\r
+        {\r
+            Contract.Requires(sender!=null);\r
+            Contract.Requires(e!=null);\r
+\r
+            if (e.ChangeType != WatcherChangeTypes.Created)\r
+                return;\r
+            var dir= new DirectoryInfo(e.FullPath);\r
+            //Skip if this is not a folder\r
+            if (!dir.Exists)\r
+                return;\r
+            foreach (var info in dir.EnumerateFileSystemInfos("*",SearchOption.AllDirectories))\r
+            {\r
+                var path = Path.GetDirectoryName(info.FullName);\r
+                Created(sender,new FileSystemEventArgs(WatcherChangeTypes.Created,path,info.Name));\r
+            }            \r
+        }\r
+\r
         private bool HandleMoved(object sender, FileSystemEventArgs e)\r
         {\r
             if (sender == null)\r
index 3b0a5b2..a644fec 100644 (file)
         {
         "Name" = "8:Microsoft Visual Studio"
         "ProductName" = "8:Pithos"
-        "ProductCode" = "8:{013ABFEC-E6FB-4C5E-930F-736A4730268A}"
-        "PackageCode" = "8:{C7D65245-240C-42FA-9E46-2AAFB3351131}"
+        "ProductCode" = "8:{871B6E5B-9773-43A7-B128-29CC044ED231}"
+        "PackageCode" = "8:{92373269-1FD4-4034-84D7-54D1E333A7E0}"
         "UpgradeCode" = "8:{205365D1-28AA-4322-A46C-FCB37502C6EF}"
         "AspNetVersion" = "8:4.0.30319.0"
         "RestartWWWService" = "11:FALSE"
         "RemovePreviousVersions" = "11:TRUE"
         "DetectNewerInstalledVersion" = "11:TRUE"
         "InstallAllUsers" = "11:FALSE"
-        "ProductVersion" = "8:0.7.20229"
+        "ProductVersion" = "8:0.7.20301"
         "Manufacturer" = "8:GRNET"
         "ARPHELPTELEPHONE" = "8:"
         "ARPHELPLINK" = "8:http://code.grnet.gr/projects/pithos-ms-client"
index fe5f650..3ee93a2 100644 (file)
         {
         "Name" = "8:Microsoft Visual Studio"
         "ProductName" = "8:Pithos"
-        "ProductCode" = "8:{CDF5C181-8F2F-4135-9861-89F031E4B435}"
-        "PackageCode" = "8:{CD80CD47-92C9-4445-A777-4110130323B8}"
+        "ProductCode" = "8:{89D5E193-BDED-4391-9258-E5CAB4EE38A1}"
+        "PackageCode" = "8:{1D7F64B1-0744-4B85-884E-474AFFABA160}"
         "UpgradeCode" = "8:{205365D1-28AA-4322-A46C-FCB37502C6EF}"
         "AspNetVersion" = "8:4.0.30319.0"
         "RestartWWWService" = "11:FALSE"
         "RemovePreviousVersions" = "11:TRUE"
         "DetectNewerInstalledVersion" = "11:TRUE"
         "InstallAllUsers" = "11:FALSE"
-        "ProductVersion" = "8:0.7.20229"
+        "ProductVersion" = "8:0.7.20301"
         "Manufacturer" = "8:GRNET"
         "ARPHELPTELEPHONE" = "8:"
         "ARPHELPLINK" = "8:http://code.grnet.gr/projects/pithos-ms-client"