nemo r122 - trunk/metadata
- From: arj svn gnome org
- To: svn-commits-list gnome org
- Subject: nemo r122 - trunk/metadata
- Date: Wed, 6 Aug 2008 14:25:41 +0000 (UTC)
Author: arj
Date: Wed Aug 6 14:25:41 2008
New Revision: 122
URL: http://svn.gnome.org/viewvc/nemo?rev=122&view=rev
Log:
More error checking
- Check if watched dir exists, otherwise nemo would crash
- Some small optimizations and a little fix if there the watched dir
becomes empty
Modified:
trunk/metadata/MetadataStore.cs
Modified: trunk/metadata/MetadataStore.cs
==============================================================================
--- trunk/metadata/MetadataStore.cs (original)
+++ trunk/metadata/MetadataStore.cs Wed Aug 6 14:25:41 2008
@@ -227,22 +227,27 @@
private void watcher_runner()
{
+ if (System.IO.Directory.Exists(watch_path)) {
watcher = new FileSystemWatcher(watch_path);
System.Console.WriteLine("watching dir {0}", watch_path);
watcher.IncludeSubdirectories = true;
- watcher.NotifyFilter = //NotifyFilters.CreationTime |
- NotifyFilters.FileName | NotifyFilters.LastAccess |
- NotifyFilters.LastWrite | NotifyFilters.Size;
+ watcher.NotifyFilter = //NotifyFilters.CreationTime |
+ NotifyFilters.FileName | NotifyFilters.LastAccess |
+ NotifyFilters.LastWrite | NotifyFilters.Size;
watcher.Error += on_watch_error;
- watcher.Changed += on_file_changed;
- watcher.Created += on_file_created;
- watcher.Deleted += on_file_deleted;
+ watcher.Changed += on_file_changed;
+ watcher.Created += on_file_created;
+ watcher.Deleted += on_file_deleted;
watcher.Renamed += on_file_renamed;
watcher.EnableRaisingEvents = true;
+ } else {
+ System.Console.WriteLine("dir to watch doesn't exist {0}", watch_path);
+ System.Environment.Exit(0);
+ }
}
private string database_dir;
@@ -264,7 +269,8 @@
public void stop()
{
- watcher.EnableRaisingEvents = false;
+ if (watcher != null)
+ watcher.EnableRaisingEvents = false;
stop_db_runner = true;
work_ready.Set(); // one last dance?
}
@@ -305,7 +311,7 @@
// fire labels event now
public void trigger_labels_changed()
{
- add_db_work(delegate { db_trigger_labels_changed(); });
+ add_db_work(db_trigger_labels_changed);
}
public void set_type_labels_changed_callback(VoidFunction<List<Tuple<FileTypeCategory, int>>> cb)
@@ -316,7 +322,7 @@
// fire labels event now
public void trigger_type_labels_changed()
{
- add_db_work(delegate { db_trigger_type_labels_changed(); });
+ add_db_work(db_trigger_type_labels_changed);
}
// set query to use for query_changed event, note DON'T touch the label
@@ -1822,10 +1828,12 @@
public void clean_database_of_nonexisting_files(List<string> paths)
{
- using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "delete from files where path not in ('" + String.Join("', '", paths.ToArray()) + "')";
- cmd.ExecuteNonQuery();
- }
+ if (paths.Count > 0) {
+ using (IDbCommand cmd = get_command()) {
+ cmd.CommandText = "delete from files where path not in ('" + String.Join("', '", paths.ToArray()) + "')";
+ cmd.ExecuteNonQuery();
+ }
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]