private void HandleFileSystemChangeEvent(Object sender, FileSystemEventArgs arg) { string note_id = GetId(arg.FullPath); if (VERBOSE_LOGGING) { Logger.Debug("NoteDirectoryWatcher: {0} has {1} (note_id={2})", arg.FullPath, arg.ChangeType, note_id); } // Record that the file has been added/changed/deleted. Adds/changes trump // deletes. Record the date. lock (file_change_records) { NoteFileChangeRecord record = null; if (file_change_records.ContainsKey(note_id)) { record = file_change_records [note_id]; } else { record = new NoteFileChangeRecord(); file_change_records [note_id] = record; } if (arg.ChangeType == WatcherChangeTypes.Changed) { record.changed = true; record.deleted = false; } else if (arg.ChangeType == WatcherChangeTypes.Created) { record.changed = true; record.deleted = false; } else if (arg.ChangeType == WatcherChangeTypes.Renamed) { record.changed = true; record.deleted = false; } else if (arg.ChangeType == WatcherChangeTypes.Deleted) { if (!record.changed) { record.deleted = true; } } else { string message = "NoteDirectoryWatcher: Unexpected WatcherChangeType " + arg.ChangeType; Logger.Error(message); return; } record.last_change = DateTime.Now; } GLib.Timeout.Add(5000, new GLib.TimeoutHandler(HandleTimeout)); }
private void HandleFileSystemChangeEvent (Object sender, FileSystemEventArgs arg) { string note_id = GetId (arg.FullPath); if (VERBOSE_LOGGING) Logger.Debug ("NoteDirectoryWatcher: {0} has {1} (note_id={2})", arg.FullPath, arg.ChangeType, note_id); // Record that the file has been added/changed/deleted. Adds/changes trump // deletes. Record the date. lock (file_change_records) { NoteFileChangeRecord record = null; if (file_change_records.ContainsKey (note_id)) { record = file_change_records [note_id]; } else { record = new NoteFileChangeRecord (); file_change_records [note_id] = record; } if (arg.ChangeType == WatcherChangeTypes.Changed) { record.changed = true; record.deleted = false; } else if (arg.ChangeType == WatcherChangeTypes.Created) { record.changed = true; record.deleted = false; } else if (arg.ChangeType == WatcherChangeTypes.Renamed) { record.changed = true; record.deleted = false; } else if (arg.ChangeType == WatcherChangeTypes.Deleted) { if (!record.changed) record.deleted = true; } else { string message = "NoteDirectoryWatcher: Unexpected WatcherChangeType " + arg.ChangeType; Logger.Error (message); return; } record.last_change = DateTime.Now; } GLib.Timeout.Add (5000, new GLib.TimeoutHandler (HandleTimeout)); }