Revision e81dd1f6 trunk/Pithos.Core/Agents/WorkflowAgent.cs

b/trunk/Pithos.Core/Agents/WorkflowAgent.cs
44 44
using System.Linq;
45 45
using System.Text;
46 46
using System.Threading.Tasks;
47
using Castle.ActiveRecord;
47 48
using Pithos.Interfaces;
48 49
using Pithos.Network;
49 50
using log4net;
......
56 57
        Agent<WorkflowState> _agent;
57 58
                
58 59
        public IStatusNotification StatusNotification { get; set; }
59
        [Import]
60
        [System.ComponentModel.Composition.Import]
60 61
        public IStatusKeeper StatusKeeper { get; set; }
61 62

  
62
        [Import]
63
        [System.ComponentModel.Composition.Import]
63 64
        public NetworkAgent NetworkAgent { get; set; }
64 65

  
65 66
        private static readonly ILog Log = LogManager.GetLogger("WorkflowAgent");
......
114 115
                        return CompletedTask<object>.Default;
115 116
                    }
116 117

  
117
                    var fileState = FileState.FindByFilePath(path);
118

  
119

  
120
                    switch (state.Status)
118
                    using (new SessionScope(FlushAction.Never))
121 119
                    {
122
                        case FileStatus.Created:
123
                        case FileStatus.Modified:
124
                            NetworkAgent.Post(new CloudUploadAction(accountInfo, info, fileState, accountInfo.BlockSize,
125
                                                                    accountInfo.BlockHash));
126
                            break;
127
                        case FileStatus.Deleted:
128
                            NetworkAgent.Post(new CloudDeleteAction(accountInfo, info, fileState));
129
                            break;
130
                        case FileStatus.Renamed:
131
                            FileSystemInfo oldInfo = Directory.Exists(state.OldPath) ? (FileSystemInfo)new DirectoryInfo(state.OldPath) : new FileInfo(state.OldPath);
132
                            FileSystemInfo newInfo = Directory.Exists(state.Path) ? (FileSystemInfo)new DirectoryInfo(state.Path) : new FileInfo(state.Path);
133
                            NetworkAgent.Post(new CloudMoveAction(accountInfo, CloudActionType.RenameCloud,
134
                                                                  oldInfo,
135
                                                                  newInfo));
136
                            break;
120

  
121
                        var fileState = FileState.FindByFilePath(path);
122

  
123

  
124
                        switch (state.Status)
125
                        {
126
                            case FileStatus.Created:
127
                            case FileStatus.Modified:
128
                                NetworkAgent.Post(new CloudUploadAction(accountInfo, info, fileState,
129
                                                                        accountInfo.BlockSize,
130
                                                                        accountInfo.BlockHash));
131
                                break;
132
                            case FileStatus.Deleted:
133
                                NetworkAgent.Post(new CloudDeleteAction(accountInfo, info, fileState));
134
                                break;
135
                            case FileStatus.Renamed:
136
                                FileSystemInfo oldInfo = Directory.Exists(state.OldPath)
137
                                                             ? (FileSystemInfo) new DirectoryInfo(state.OldPath)
138
                                                             : new FileInfo(state.OldPath);
139
                                FileSystemInfo newInfo = Directory.Exists(state.Path)
140
                                                             ? (FileSystemInfo) new DirectoryInfo(state.Path)
141
                                                             : new FileInfo(state.Path);
142
                                NetworkAgent.Post(new CloudMoveAction(accountInfo, CloudActionType.RenameCloud,
143
                                                                      oldInfo,
144
                                                                      newInfo));
145
                                break;
146
                        }
137 147
                    }
138 148

  
139 149
                    return CompletedTask<object>.Default;

Also available in: Unified diff