Revision 26d5f45f

b/trunk/Pithos.Core/Agents/WorkflowAgent.cs
126 126
                                                                        accountInfo.BlockHash));
127 127
                                break;
128 128
                            case FileStatus.Deleted:
129
                                if (fileState != null)
130
                                {
131
                                    var children = StatusKeeper.GetChildren(fileState);
132
                                    foreach (var child in children)
133
                                    {
134
                                        var childInfo = child.IsFolder
135
                                                            ? (FileSystemInfo) new DirectoryInfo(child.FilePath)
136
                                                            : new FileInfo(child.FilePath);
137
                                        NetworkAgent.Post(new CloudDeleteAction(accountInfo, childInfo, child));
138
                                    }
139
                                }
129
                                DeleteChildObjects(state, fileState);
140 130
                                NetworkAgent.Post(new CloudDeleteAction(accountInfo, info, fileState));
141 131
                                break;
142 132
                            case FileStatus.Renamed:
......
148 138
                                                             : new FileInfo(state.Path);
149 139
                                NetworkAgent.Post(new CloudMoveAction(accountInfo, CloudActionType.RenameCloud,
150 140
                                                                      oldInfo,
151
                                                                      newInfo));
141
                                                                      newInfo));                                
142
                                //TODO: Do I have to move children as well or will Pithos handle this?
143
                               //Need to find all children of the OLD filepath
144
                                MoveChildObjects(state);
152 145
                                break;
153 146
                        }
154 147
                    }
......
163 156
            }
164 157
        }
165 158

  
159
        private void DeleteChildObjects(WorkflowState state, FileState fileState)
160
        {
161
            if (fileState != null)
162
            {
163
                var children = StatusKeeper.GetChildren(fileState);
164
                foreach (var child in children)
165
                {
166
                    var childInfo = child.IsFolder
167
                                        ? (FileSystemInfo) new DirectoryInfo(child.FilePath)
168
                                        : new FileInfo(child.FilePath);
169
                    NetworkAgent.Post(new CloudDeleteAction(state.AccountInfo, childInfo, child));
170
                }
171
            }
172
        }
173

  
174
        private void MoveChildObjects(WorkflowState state)
175
        {
176
            var oldFileState = StatusKeeper.GetStateByFilePath(state.OldPath);
177
            if (oldFileState != null)
178
            {
179
                var children = StatusKeeper.GetChildren(oldFileState);
180
                foreach (var child in children)
181
                {
182
                    var newPath = Path.Combine(state.Path, child.FilePath.Substring(state.OldPath.Length+1));
183

  
184
                    var oldMoveInfo = child.IsFolder
185
                                          ? (FileSystemInfo) new DirectoryInfo(child.FilePath)
186
                                          : new FileInfo(child.FilePath);
187
                    var newMoveInfo = child.IsFolder
188
                                          ? (FileSystemInfo) new DirectoryInfo(newPath)
189
                                          : new FileInfo(newPath);
190
                    //The new file path will be created by trimming the old root path
191
                    //and substituting the new root path
192

  
193
                    NetworkAgent.Post(new CloudMoveAction(state.AccountInfo, CloudActionType.RenameCloud,
194
                                                          oldMoveInfo, newMoveInfo));
195
                }
196
            }
197
        }
198

  
166 199

  
167 200
        //Starts interrupted files for a specific account
168 201
        public void RestartInterruptedFiles(AccountInfo accountInfo)

Also available in: Unified diff