Convert ActiveRecord update code to direct ADO calls to reduce locks
[pithos-ms-client] / trunk / Pithos.Core / Agents / NetworkAgent.cs
index 940c9f4..8c4792c 100644 (file)
@@ -45,6 +45,7 @@ using System.IO;
 using System.Linq;
 using System.Net;
 using System.Threading.Tasks;
+using Castle.ActiveRecord;
 using Pithos.Interfaces;
 using Pithos.Network;
 using log4net;
@@ -61,7 +62,7 @@ namespace Pithos.Core.Agents
         private Agent<CloudDeleteAction> _deleteAgent;
 
 
-        [Import]
+        [System.ComponentModel.Composition.Import]
         public IStatusKeeper StatusKeeper { get; set; }
         
         public IStatusNotification StatusNotification { get; set; }
@@ -352,7 +353,7 @@ namespace Pithos.Core.Agents
             Contract.EndContractBlock();
 
             //If the action targets a local file, add a treehash calculation
-            if (cloudAction.LocalFile as FileInfo != null)
+            if (!(cloudAction is CloudDeleteAction) && cloudAction.LocalFile as FileInfo != null)
             {
                 var accountInfo = cloudAction.AccountInfo;
                 var localFile = (FileInfo) cloudAction.LocalFile;
@@ -548,12 +549,15 @@ namespace Pithos.Core.Agents
                     var localFile = fileAgent.GetFileSystemInfo(relativePath);
                     if (objectInfo.Content_Type == @"application/directory" && localFile is DirectoryInfo)
                         continue;
-                    var state = FileState.FindByFilePath(localFile.FullName);
-                    //Common files should be checked on a per-case basis to detect differences, which is newer
+                    using (new SessionScope(FlushAction.Never))
+                    {
+                        var state = FileState.FindByFilePath(localFile.FullName);
+                        //Common files should be checked on a per-case basis to detect differences, which is newer
 
-                    yield return new CloudAction(accountInfo,CloudActionType.MustSynch,
-                                                   localFile, objectInfo, state, accountInfo.BlockSize,
-                                                   accountInfo.BlockHash);
+                        yield return new CloudAction(accountInfo, CloudActionType.MustSynch,
+                                                     localFile, objectInfo, state, accountInfo.BlockSize,
+                                                     accountInfo.BlockHash);
+                    }
                 }
                 else
                 {