Bugzilla – Attachment 49142 Details for
Bug 113869
Beagle will sometimes not notice moves
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
[patch]
a patch which fixes this problem
02-bnc-113869-file-system-problems.patch (text/plain), 7.42 KB, created by
Jon Trowbridge
on 2005-09-08 02:40:20 UTC
(
hide
)
Description:
a patch which fixes this problem
Filename:
MIME Type:
Creator:
Jon Trowbridge
Created:
2005-09-08 02:40:20 UTC
Size:
7.42 KB
patch
obsolete
>Index: beagled/FileSystemQueryable/FileSystemQueryable.cs >=================================================================== >RCS file: /cvs/gnome/beagle/beagled/FileSystemQueryable/FileSystemQueryable.cs,v >retrieving revision 1.81 >retrieving revision 1.84 >diff -u -p -r1.81 -r1.84 >--- beagled/FileSystemQueryable/FileSystemQueryable.cs 1 Sep 2005 04:46:23 -0000 1.81 >+++ beagled/FileSystemQueryable/FileSystemQueryable.cs 7 Sep 2005 03:20:11 -0000 1.84 >@@ -76,7 +76,7 @@ namespace Beagle.Daemon.FileSystemQuerya > > ////////////////////////////////////////////////////////////////////////// > >- private Hashtable pending_moves_uid_by_path = new Hashtable (); >+ private Hashtable cached_uid_by_path = new Hashtable (); > > ////////////////////////////////////////////////////////////////////////// > >@@ -324,6 +324,33 @@ namespace Beagle.Daemon.FileSystemQuerya > return ToFullPath (info.Name, info.ParentId); > } > >+ private void RegisterId (string name, DirectoryModel dir, Guid id) >+ { >+ cached_uid_by_path [Path.Combine (dir.FullName, name)] = id; >+ } >+ >+ private void ForgetId (string path) >+ { >+ cached_uid_by_path.Remove (path); >+ } >+ >+ // This works for files. (It probably works for directories >+ // too, but you should use one of the more efficient means >+ // above if you know it is a directory.) >+ private Guid NameAndParentToId (string name, DirectoryModel dir) >+ { >+ string path; >+ path = Path.Combine (dir.FullName, name); >+ >+ Guid unique_id; >+ if (cached_uid_by_path.Contains (path)) >+ unique_id = (Guid) cached_uid_by_path [path]; >+ else >+ unique_id = name_resolver.GetIdByNameAndParentId (name, dir.UniqueId); >+ >+ return unique_id; >+ } >+ > ////////////////////////////////////////////////////////////////////////// > > // >@@ -360,17 +387,8 @@ namespace Beagle.Daemon.FileSystemQuerya > if (Debug) > Logger.Log.Debug ("Expired '{0}'", expired_path); > >-#if false >- DirectoryModel dir = (DirectoryModel) dir_models_by_id [unique_id]; >- if (dir != null && dir.WatchHandle != null) >- event_backend.ForgetWatch (dir.WatchHandle); >-#endif >- lock (dir_models_by_id) >+ lock (dir_models_by_path) > dir_models_by_path.Remove (expired_path); >- >-#if false >- dir_models_by_id.Remove (unique_id); >-#endif > } > > public void AddDirectory (DirectoryModel parent, string name) >@@ -553,6 +571,17 @@ namespace Beagle.Daemon.FileSystemQuerya > ActivateFileCrawling (); > } > >+ private void ForgetDirectoryRecursively (DirectoryModel dir) >+ { >+ foreach (DirectoryModel child in dir.Children) >+ ForgetDirectoryRecursively (child); >+ >+ if (dir.WatchHandle != null) >+ event_backend.ForgetWatch (dir.WatchHandle); >+ dir_models_by_id.Remove (dir.UniqueId); >+ // We rely on the expire event to remove it from dir_models_by_path >+ } >+ > private void RemoveDirectory (DirectoryModel dir) > { > Uri uri; >@@ -565,6 +594,9 @@ namespace Beagle.Daemon.FileSystemQuerya > // easily remap it in the PostRemoveHook. > indexable.LocalState ["RemovedUri"] = UriFu.PathToFileUri (dir.FullName); > >+ // Forget watches and internal references >+ ForgetDirectoryRecursively (dir); >+ > // Calling Remove will expire the path names, > // so name caches will be cleaned up accordingly. > dir.Remove (); >@@ -586,6 +618,13 @@ namespace Beagle.Daemon.FileSystemQuerya > DirectoryModel new_parent, // or null if we are just renaming > string new_name) > { >+ if (dir == null) { >+ Logger.Log.Warn ("Couldn't find DirectoryModel for directory moving to '{0}' in '{1}', so it was hopefully never there.", >+ new_name, new_parent.FullName); >+ AddDirectory (new_parent, new_name); >+ return; >+ } >+ > if (dir.IsRoot) > throw new Exception ("Can't move root " + dir.FullName); > >@@ -934,6 +973,8 @@ namespace Beagle.Daemon.FileSystemQuerya > Guid unique_id; > unique_id = (attr != null) ? attr.UniqueId : Guid.NewGuid (); > >+ RegisterId (name, dir, unique_id); >+ > Indexable indexable; > indexable = FileToIndexable (path, unique_id, dir, false); > >@@ -949,10 +990,10 @@ namespace Beagle.Daemon.FileSystemQuerya > // Right? > > Guid unique_id; >- unique_id = name_resolver.GetIdByNameAndParentId (name, dir.UniqueId); >+ unique_id = NameAndParentToId (name, dir); > if (unique_id == Guid.Empty) { >- Logger.Log.Warn ("Couldn't find unique id for '{0}' in '{1}' ({2})", >- name, dir.FullName, dir.UniqueId); >+ Logger.Log.Warn ("Could resolve unique id of '{0}' in '{1}' for removal, it is probably already gone", >+ name, dir.FullName); > return; > } > >@@ -965,7 +1006,7 @@ namespace Beagle.Daemon.FileSystemQuerya > indexable.LocalState ["RemovedUri"] = file_uri; > > Scheduler.Task task; >- task = NewRemoveTask (uri); >+ task = NewAddTask (indexable); > task.Priority = Scheduler.Priority.Immediate; > ThisScheduler.Add (task); > } >@@ -993,36 +1034,27 @@ namespace Beagle.Daemon.FileSystemQuerya > return; > } > >- string old_path; >- old_path = Path.Combine (old_dir.FullName, old_name); >- > // We need to find the file's unique id. > // We can't look at the extended attributes w/o making > // assumptions about whether they follow around the >- // file (EAs) or the path (sqlite), so here is what we do: >- // (1) Look at the pending_moves_uid_by_path hash. This will >- // contain info about things that aren't in the index yet. >- // (2) If that fails, look in the index using the name resolver. >- // to the name resolver. >- >+ // file (EAs) or the path (sqlite)... > Guid unique_id; >- if (pending_moves_uid_by_path.Contains (old_path)) { >- unique_id = (Guid) pending_moves_uid_by_path [old_path]; >- pending_moves_uid_by_path.Remove (old_path); >- } else { >- unique_id = name_resolver.GetIdByNameAndParentId (old_name, old_dir.UniqueId); >- if (unique_id == Guid.Empty) { >- Logger.Log.Warn ("Couldn't find unique id for '{0}' in '{1}' ({2})", >- old_name, old_dir.FullName, old_dir.UniqueId); >+ unique_id = NameAndParentToId (old_name, old_dir); >+ if (unique_id == Guid.Empty) { >+ // If we can't find the unique ID, we have to >+ // assume that the original file never made it >+ // into the index --- thus we treat this as >+ // an Add. >+ AddFile (new_dir, new_name); > return; >- } > } >- >- Logger.Log.Debug ("Guid of {0} is {1}", old_path, GuidFu.ToShortString (unique_id)); > >- string new_path; >- new_path = Path.Combine (new_dir.FullName, new_name); >- pending_moves_uid_by_path [new_path] = unique_id; >+ RegisterId (new_name, new_dir, unique_id); >+ >+ string old_path; >+ old_path = Path.Combine (old_dir.FullName, old_name); >+ >+ ForgetId (old_path); > > // FIXME: I think we need to be more conservative when we seen > // events in a directory that has not been fully scanned, just to >@@ -1111,13 +1143,14 @@ namespace Beagle.Daemon.FileSystemQuerya > > // This rename is now in the index, so we no longer need to keep > // track of the uid in memory. >- pending_moves_uid_by_path.Remove (last_known_path); >+ ForgetId (last_known_path); > > return; > } > > string path; > path = (string) indexable.LocalState ["Path"]; >+ ForgetId (path); > > DirectoryModel parent; > parent = indexable.LocalState ["Parent"] as DirectoryModel; >@@ -1159,6 +1192,7 @@ namespace Beagle.Daemon.FileSystemQuerya > if (external_uri == null) > throw new Exception ("No cached external Uri for " + receipt.Uri); > receipt.Uri = external_uri; >+ ForgetId (external_uri.LocalPath); > } > > private bool RemapUri (Hit hit)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 113869
: 49142