Revision 139ac1e8

b/trunk/Pithos.Core/Agents/FileAgent.cs
104 104
                loop = () =>
105 105
                {
106 106
                    var message = inbox.Receive();
107
                    var process=message.Then(Process,inbox.CancellationToken);
108

  
107
                    var process=message.Then(Process,inbox.CancellationToken);                    
109 108
                    inbox.LoopAsync(process,loop,ex=>
110 109
                        Log.ErrorFormat("[ERROR] File Event Processing:\r{0}", ex));
111 110
                };
......
246 245

  
247 246
        private bool Ignore(string filePath)
248 247
        {
249
            //Ignore all first-level directories and files            
248
            //Ignore all first-level directories and files (ie at the container folders level)
250 249
            if (FoundBelowRoot(filePath, RootPath,1))
251
                return true;            
250
                return true;
252 251

  
253
            //Ignore first-level items under the "others" folder.
252
            //Ignore first-level items under the "others" folder (ie at the accounts folders level).
254 253
            var othersPath = Path.Combine(RootPath, FolderConstants.OthersFolder);
255 254
            if (FoundBelowRoot(filePath, othersPath,1))
256
                return true;            
255
                return true;
257 256

  
258
            //Ignore second-level (container) folders under the "others" folder. 
257
            //Ignore second-level (container) folders under the "others" folder (ie at the container folders level). 
259 258
            if (FoundBelowRoot(filePath, othersPath,2))
260 259
                return true;            
261 260

  
......
265 264
                return true;
266 265
            if (_ignoreFiles.ContainsKey(filePath.ToLower()))
267 266
                return true;
267

  
268
            //If selective synchronization is defined, 
269
            if (SelectivePaths.Count>0)
270
            {
271
                //Abort if the file is not located under any of the selected folders
272
                if (!SelectivePaths.Any(filePath.StartsWith))
273
                    return true;
274
            }
275

  
268 276
            return false;
269 277
        }
270 278

  
b/trunk/Pithos.Core/Agents/FileSystemWatcherAdapter.cs
42 42
using System.Diagnostics.Contracts;
43 43
using System.IO;
44 44
using System.Threading.Tasks;
45
using Pithos.Interfaces;
45 46

  
46 47
namespace Pithos.Core.Agents
47 48
{
......
106 107
            //      as this is actually a MOVE operation
107 108
            //Deleting by Shift+Delete results in a delete event for each file followed by the delete of the folder itself
108 109
            _cachedDeletedFullPath = e.FullPath;
109

  
110
            
110 111
            //TODO: This requires synchronization of the _cachedDeletedFullPath field
111 112
            //TODO: This creates a new task for each file even though we can cancel any existing tasks if a new event arrives
112 113
            //Maybe, use a timer instead of a task
......
199 200
                //If the actual action is a Move, raise a Move event instead of the actual event
200 201
                var newDirectory = Path.GetDirectoryName(e.FullPath);
201 202
                var oldDirectory = Path.GetDirectoryName(_cachedDeletedFullPath);
203

  
202 204
                if (Moved != null)
205
                {
203 206
                    Moved(sender, new MovedEventArgs(newDirectory, newName, oldDirectory, oldName));
207
                    //If the moved item is a dictionary, we need to raise a change event for each child item
208
                    //When a directory is moved within the same volume, Windows raises events only for the directory object,
209
                    //not its children. This happens because the move actually changes a single directory entry. It doesn't
210
                    //affect the entries of the children.
211
                    var directory = new DirectoryInfo(e.FullPath);
212
                    if (directory.Exists)
213
                    {
214
                        foreach (var child in directory.EnumerateFileSystemInfos("*", SearchOption.AllDirectories))
215
                        {
216
                            var newChildDirectory = Path.GetDirectoryName(child.FullName);
217

  
218
                            var relativePath=child.AsRelativeTo(newDirectory);
219
                            var relativeFolder = Path.GetDirectoryName(relativePath);
220
                            var oldChildDirectory = Path.Combine(oldDirectory, relativeFolder);
221
                            Moved(sender,new MovedEventArgs(newChildDirectory,child.Name,oldChildDirectory,child.Name));
222
                        }
223
                    }
224

  
225
                }
226

  
204 227
            }
205 228
            finally
206 229
            {
......
223 246
            var deletedFileName = Path.GetFileName(_cachedDeletedFullPath);
224 247
            var deletedFileDirectory = Path.GetDirectoryName(_cachedDeletedFullPath);
225 248

  
226
            if (Deleted!=null)
227
                Deleted(sender, new FileSystemEventArgs(WatcherChangeTypes.Deleted, deletedFileDirectory, deletedFileName));
249
            //Only a single file Delete event is raised when moving a file to the Recycle Bin, as this is actually a MOVE operation
250
            //In this case we need to raise the proper events for all child objects of the deleted directory.
251
            //UNFORTUNATELY, this can't be detected here, eg. by retrieving the child objects, because they are already deleted
252
            //This should be done at a higher level, eg by checking the stored state
253
            if (Deleted != null)            
254
                Deleted(sender,new FileSystemEventArgs(WatcherChangeTypes.Deleted, deletedFileDirectory, deletedFileName));
228 255

  
229 256
            _cachedDeletedFullPath = null;
230 257
        }
b/trunk/Pithos.Core/Agents/WorkflowAgent.cs
145 145
                                                                      newInfo));                                
146 146
                                //TODO: Do I have to move children as well or will Pithos handle this?
147 147
                               //Need to find all children of the OLD filepath
148
                                MoveChildObjects(state);
148
                                //MoveChildObjects(state);
149 149
                                break;
150 150
                        }
151 151
                    }
......
160 160
            }
161 161
        }
162 162

  
163

  
163 164
        private void DeleteChildObjects(WorkflowState state, FileState fileState)
164 165
        {
165 166
            if (fileState != null)
......
175 176
            }
176 177
        }
177 178

  
178
        private void MoveChildObjects(WorkflowState state)
179
        /*private void MoveChildObjects(WorkflowState state)
179 180
        {
180 181
            var oldFileState = StatusKeeper.GetStateByFilePath(state.OldPath);
181 182
            if (oldFileState != null)
......
198 199
                                                          oldMoveInfo, newMoveInfo));
199 200
                }
200 201
            }
201
        }
202
        }*/
202 203

  
203 204

  
204 205
        //Starts interrupted files for a specific account
b/trunk/Pithos.Network/TreeHash.cs
89 89
            get { return _topHash.Value; }
90 90
        }
91 91

  
92
        private IList<byte[]> _hashes;
92
        private IList<byte[]> _hashes=new List<byte[]>();
93 93

  
94 94
        public IList<byte[]> Hashes
95 95
        {

Also available in: Unified diff