nemo r125 - trunk/metadata
- From: arj svn gnome org
- To: svn-commits-list gnome org
- Subject: nemo r125 - trunk/metadata
- Date: Tue, 19 Aug 2008 11:50:54 +0000 (UTC)
Author: arj
Date: Tue Aug 19 11:50:53 2008
New Revision: 125
URL: http://svn.gnome.org/viewvc/nemo?rev=125&view=rev
Log:
Add more debug to metadata store in order to find out why ##529998 happens
Modified:
trunk/metadata/MetadataStore.cs
Modified: trunk/metadata/MetadataStore.cs
==============================================================================
--- trunk/metadata/MetadataStore.cs (original)
+++ trunk/metadata/MetadataStore.cs Tue Aug 19 11:50:53 2008
@@ -1182,12 +1182,16 @@
private void add_file_type(IDbCommand cmd, string type, FileTypeCategory category)
{
- cmd.CommandText = "insert into file_types (type, category) " +
- "values (@type, @category);";
- cmd.Parameters.Clear();
- add_par(cmd, "@type", DbType.String, type);
- add_par(cmd, "@category", DbType.Int32, (int)category);
- cmd.ExecuteNonQuery();
+ try {
+ cmd.CommandText = "insert into file_types (type, category) " +
+ "values (@type, @category);";
+ cmd.Parameters.Clear();
+ add_par(cmd, "@type", DbType.String, type);
+ add_par(cmd, "@category", DbType.Int32, (int)category);
+ cmd.ExecuteNonQuery();
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while adding file type: {0} - {1}", e.Message, cmd.CommandText);
+ }
}
public long get_file_id(string path, out bool found)
@@ -1231,103 +1235,127 @@
DateTime last_modified, long size, long filetype_id)
{
// System.Console.WriteLine("inserting {0}", path);
-
- using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "insert into files (path, last_accessed, last_modified, size, type, starred) " +
- "values (@path, @last_accessed, @last_modified, @size, @filetype_id, 0)";
+
+ using (IDbCommand cmd = get_command()) {
+ try {
+ cmd.CommandText = "insert into files (path, last_accessed, last_modified, size, type, starred) " +
+ "values (@path, @last_accessed, @last_modified, @size, @filetype_id, 0)";
- cmd.Parameters.Clear();
- add_par(cmd, "@path", DbType.String, path);
- add_par(cmd, "@last_accessed", DbType.Int64, last_accessed.ToFileTime());
- add_par(cmd, "@last_modified", DbType.Int64, last_modified.ToFileTime());
- add_par(cmd, "@size", DbType.Int64, size);
- add_par(cmd, "@filetype_id", DbType.Int64, filetype_id);
- cmd.ExecuteNonQuery();
- }
+ cmd.Parameters.Clear();
+ add_par(cmd, "@path", DbType.String, path);
+ add_par(cmd, "@last_accessed", DbType.Int64, last_accessed.ToFileTime());
+ add_par(cmd, "@last_modified", DbType.Int64, last_modified.ToFileTime());
+ add_par(cmd, "@size", DbType.Int64, size);
+ add_par(cmd, "@filetype_id", DbType.Int64, filetype_id);
+ cmd.ExecuteNonQuery();
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while adding file: {0} - {1}", e.Message, cmd.CommandText);
}
+ }
+ }
public void updated_starred_state_on_file(long id, bool starred)
{
- using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "update files set " +
- "starred = @starred " +
- "where id = @id";
- cmd.Parameters.Clear();
- add_par(cmd, "@id", DbType.Int64, id);
- add_par(cmd, "@starred", DbType.Int32, starred);
- cmd.ExecuteNonQuery();
- }
+ using (IDbCommand cmd = get_command()) {
+ try {
+ cmd.CommandText = "update files set " +
+ "starred = @starred " +
+ "where id = @id";
+ cmd.Parameters.Clear();
+ add_par(cmd, "@id", DbType.Int64, id);
+ add_par(cmd, "@starred", DbType.Int32, starred);
+ cmd.ExecuteNonQuery();
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while updating star state on file: {0} - {1}", e.Message, cmd.CommandText);
+ }
+ }
}
public void update_file(long id, string path, DateTime last_accessed,
DateTime last_modified, long size, long filetype_id)
{
- using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "update files set " +
- "last_accessed = @last_accessed, " +
- "last_modified = @last_modified, " +
- "size = @size, " +
- "type = @filetype_id " +
- "where id = @id";
- cmd.Parameters.Clear();
- add_par(cmd, "@id", DbType.Int64, id);
- add_par(cmd, "@last_accessed", DbType.Int64, last_accessed.ToFileTime());
- add_par(cmd, "@last_modified", DbType.Int64, last_modified.ToFileTime());
- add_par(cmd, "@size", DbType.Int64, size);
- add_par(cmd, "@filetype_id", DbType.Int64, filetype_id);
- cmd.ExecuteNonQuery();
- }
+ using (IDbCommand cmd = get_command()) {
+ try {
+ cmd.CommandText = "update files set " +
+ "last_accessed = @last_accessed, " +
+ "last_modified = @last_modified, " +
+ "size = @size, " +
+ "type = @filetype_id " +
+ "where id = @id";
+ cmd.Parameters.Clear();
+ add_par(cmd, "@id", DbType.Int64, id);
+ add_par(cmd, "@last_accessed", DbType.Int64, last_accessed.ToFileTime());
+ add_par(cmd, "@last_modified", DbType.Int64, last_modified.ToFileTime());
+ add_par(cmd, "@size", DbType.Int64, size);
+ add_par(cmd, "@filetype_id", DbType.Int64, filetype_id);
+ cmd.ExecuteNonQuery();
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while updating file: {0} - {1}", e.Message, cmd.CommandText);
+ }
+ }
}
public void update_type_for_file(long file_id, long filetype_id)
{
- using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "update files set " +
- "type = @filetype_id " +
- "where id = @file_id";
- cmd.Parameters.Clear();
- add_par(cmd, "@file_id", DbType.Int64, file_id);
- add_par(cmd, "@filetype_id", DbType.Int64, filetype_id);
- cmd.ExecuteNonQuery();
- }
+ using (IDbCommand cmd = get_command()) {
+ try {
+ cmd.CommandText = "update files set " +
+ "type = @filetype_id " +
+ "where id = @file_id";
+ cmd.Parameters.Clear();
+ add_par(cmd, "@file_id", DbType.Int64, file_id);
+ add_par(cmd, "@filetype_id", DbType.Int64, filetype_id);
+ cmd.ExecuteNonQuery();
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while updating type on file: {0} - {1}", e.Message, cmd.CommandText);
+ }
+ }
}
public void delete_file(string path)
{
- using (IDbCommand cmd = get_command()) {
- bool id_found = false;
- long id = get_file_id(path, out id_found);
-
- if (id_found) {
- System.Console.WriteLine("deleting labels for {0}", path);
- cmd.CommandText = "delete from file_labels where file_id = @id";
- cmd.Parameters.Clear();
- add_par(cmd, "@id", DbType.Int64, id);
- cmd.ExecuteNonQuery();
-
- System.Console.WriteLine("deleting {0}", path);
- cmd.CommandText = "delete from files where id = @id";
- cmd.Parameters.Clear();
- add_par(cmd, "@id", DbType.Int64, id);
- cmd.ExecuteNonQuery();
- }
- }
+ using (IDbCommand cmd = get_command()) {
+ try {
+ bool id_found = false;
+ long id = get_file_id(path, out id_found);
+
+ if (id_found) {
+ System.Console.WriteLine("deleting labels for {0}", path);
+ cmd.CommandText = "delete from file_labels where file_id = @id";
+ cmd.Parameters.Clear();
+ add_par(cmd, "@id", DbType.Int64, id);
+ cmd.ExecuteNonQuery();
+
+ System.Console.WriteLine("deleting {0}", path);
+ cmd.CommandText = "delete from files where id = @id";
+ cmd.Parameters.Clear();
+ add_par(cmd, "@id", DbType.Int64, id);
+ cmd.ExecuteNonQuery();
+ }
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while deleting file: {0} - {1}", e.Message, cmd.CommandText);
+ }
+ }
}
public void rename_file(long file_id, string path)
{
- using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "update files set path = @path where id = @file_id";
- cmd.Parameters.Clear();
- add_par(cmd, "@path", DbType.String, path);
- add_par(cmd, "@file_id", DbType.Int64, file_id);
- System.Console.WriteLine("renaming {0} to {1}", file_id, path);
- }
+ using (IDbCommand cmd = get_command()) {
+ try {
+ cmd.CommandText = "update files set path = @path where id = @file_id";
+ cmd.Parameters.Clear();
+ add_par(cmd, "@path", DbType.String, path);
+ add_par(cmd, "@file_id", DbType.Int64, file_id);
+ System.Console.WriteLine("renaming {0} to {1}", file_id, path);
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while renaming file: {0} - {1}", e.Message, cmd.CommandText);
+ }
+ }
}
public List<string> get_file_paths_in_directory(string directory_path)
{
- Debug.Assert(!directory_path.EndsWith("/"));
+ Debug.Assert(!directory_path.EndsWith("/"));
using (IDbCommand cmd = get_command()) {
cmd.CommandText = String.Format("select path from files where path like \"{0}{1}%\" and path not like \"{0}{1}%{1}%\" order by path", directory_path, Path.DirectorySeparatorChar);
@@ -1413,16 +1441,20 @@
}
}
- using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "insert into labels (label, color, parent) " +
- "values (@label, @color, @parent)";
-
- cmd.Parameters.Clear();
- add_par(cmd, "@label", DbType.String, label.label);
- add_par(cmd, "@color", DbType.Int32, index);
- add_par(cmd, "@parent", DbType.Int64, label.parent_db_id);
- cmd.ExecuteNonQuery();
- }
+ using (IDbCommand cmd = get_command()) {
+ try {
+ cmd.CommandText = "insert into labels (label, color, parent) " +
+ "values (@label, @color, @parent)";
+
+ cmd.Parameters.Clear();
+ add_par(cmd, "@label", DbType.String, label.label);
+ add_par(cmd, "@color", DbType.Int32, index);
+ add_par(cmd, "@parent", DbType.Int64, label.parent_db_id);
+ cmd.ExecuteNonQuery();
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while adding label 1: {0} - {1}", e.Message, cmd.CommandText);
+ }
+ }
Int32 number_of_colors = 1;
@@ -1435,25 +1467,33 @@
}
}
- using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "update label_colors_index set id = @newid";
-
- cmd.Parameters.Clear();
- add_par(cmd, "@newid", DbType.Int32, index % number_of_colors + 1);
- cmd.ExecuteNonQuery();
- }
+ using (IDbCommand cmd = get_command()) {
+ try {
+ cmd.CommandText = "update label_colors_index set id = @newid";
+
+ cmd.Parameters.Clear();
+ add_par(cmd, "@newid", DbType.Int32, index % number_of_colors + 1);
+ cmd.ExecuteNonQuery();
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while adding label 2: {0} - {1}", e.Message, cmd.CommandText);
+ }
+ }
}
public void rename_label(long label_id, string new_name)
{
- using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "update labels set label = @label where id = @id";
- cmd.Parameters.Clear();
- add_par(cmd, "@label", DbType.String, new_name);
- add_par(cmd, "@id", DbType.Int64, label_id);
- cmd.ExecuteNonQuery();
- System.Console.WriteLine("renaming {0} to {1}", label_id, new_name);
- }
+ using (IDbCommand cmd = get_command()) {
+ try {
+ cmd.CommandText = "update labels set label = @label where id = @id";
+ cmd.Parameters.Clear();
+ add_par(cmd, "@label", DbType.String, new_name);
+ add_par(cmd, "@id", DbType.Int64, label_id);
+ cmd.ExecuteNonQuery();
+ System.Console.WriteLine("renaming {0} to {1}", label_id, new_name);
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while renaming label: {0} - {1}", e.Message, cmd.CommandText);
+ }
+ }
}
public List<MetaLabel> get_labels()
@@ -1543,48 +1583,60 @@
if (!file_exists(file_id) || !label_exists(label_id))
return;
- using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "insert into file_labels (file_id, label_id) " +
- "values (@file_id, @label_id)";
-
- cmd.Parameters.Clear();
- add_par(cmd, "@file_id", DbType.Int64, file_id);
- add_par(cmd, "@label_id", DbType.Int64, label_id);
- cmd.ExecuteNonQuery();
- }
+ using (IDbCommand cmd = get_command()) {
+ try {
+ cmd.CommandText = "insert into file_labels (file_id, label_id) " +
+ "values (@file_id, @label_id)";
+
+ cmd.Parameters.Clear();
+ add_par(cmd, "@file_id", DbType.Int64, file_id);
+ add_par(cmd, "@label_id", DbType.Int64, label_id);
+ cmd.ExecuteNonQuery();
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while adding label to file id: {0} - {1}", e.Message, cmd.CommandText);
+ }
+ }
}
public void remove_label_from_file_id(long file_id, long label_id)
{
- using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "delete from file_labels " +
- "where file_id = @file_id " +
- "and label_id = @label_id";
-
- cmd.Parameters.Clear();
- add_par(cmd, "@file_id", DbType.Int64, file_id);
- add_par(cmd, "@label_id", DbType.Int64, label_id);
- cmd.ExecuteNonQuery();
- }
+ using (IDbCommand cmd = get_command()) {
+ try {
+ cmd.CommandText = "delete from file_labels " +
+ "where file_id = @file_id " +
+ "and label_id = @label_id";
+
+ cmd.Parameters.Clear();
+ add_par(cmd, "@file_id", DbType.Int64, file_id);
+ add_par(cmd, "@label_id", DbType.Int64, label_id);
+ cmd.ExecuteNonQuery();
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while removing label from file id: {0} - {1}", e.Message, cmd.CommandText);
+ }
+ }
}
public void delete_label(long label_id)
{
- using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "delete from file_labels " +
- "where label_id = @label_id";
-
- cmd.Parameters.Clear();
- add_par(cmd, "@label_id", DbType.Int64, label_id);
- cmd.ExecuteNonQuery();
-
- cmd.CommandText = "delete from labels " +
- "where id = @label_id";
+ using (IDbCommand cmd = get_command()) {
+ try {
+ cmd.CommandText = "delete from file_labels " +
+ "where label_id = @label_id";
+
+ cmd.Parameters.Clear();
+ add_par(cmd, "@label_id", DbType.Int64, label_id);
+ cmd.ExecuteNonQuery();
+
+ cmd.CommandText = "delete from labels " +
+ "where id = @label_id";
- cmd.Parameters.Clear();
- add_par(cmd, "@label_id", DbType.Int64, label_id);
- cmd.ExecuteNonQuery();
- }
+ cmd.Parameters.Clear();
+ add_par(cmd, "@label_id", DbType.Int64, label_id);
+ cmd.ExecuteNonQuery();
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while deleting label: {0} - {1}", e.Message, cmd.CommandText);
+ }
+ }
}
private void construct_query_sql(IDbCommand cmd, Query query, string select, string extraclause)
@@ -1830,8 +1882,12 @@
{
if (paths.Count > 0) {
using (IDbCommand cmd = get_command()) {
- cmd.CommandText = "delete from files where path not in ('" + String.Join("', '", paths.ToArray()) + "')";
- cmd.ExecuteNonQuery();
+ try {
+ cmd.CommandText = "delete from files where path not in ('" + String.Join("', '", paths.ToArray()) + "')";
+ cmd.ExecuteNonQuery();
+ } catch (Exception e) {
+ System.Console.WriteLine("Caught exception while cleaning nonexisting files: {0} - {1}", e.Message, cmd.CommandText);
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]