beagle r4404 - trunk/beagle/beagled



Author: kkubasik
Date: Sat Jan 19 07:23:37 2008
New Revision: 4404
URL: http://svn.gnome.org/viewvc/beagle?rev=4404&view=rev

Log:
Formatting fixes for last Sqlite commit

Modified:
   trunk/beagle/beagled/FileAttributesStore_Sqlite.cs
   trunk/beagle/beagled/SqliteUtils.cs
   trunk/beagle/beagled/TextCache.cs

Modified: trunk/beagle/beagled/FileAttributesStore_Sqlite.cs
==============================================================================
--- trunk/beagle/beagled/FileAttributesStore_Sqlite.cs	(original)
+++ trunk/beagle/beagled/FileAttributesStore_Sqlite.cs	Sat Jan 19 07:23:37 2008
@@ -183,14 +183,14 @@
 				Logger.Log.Debug ("Loaded {0} records from {1} in {2:0.000}s", 
 						 count, GetDbPath (directory), (dt2 - dt1).TotalSeconds);
 			}
-			ReadCommand = new SqliteCommand(this.connection);
+			ReadCommand = new SqliteCommand (this.connection);
 			ReadCommand.CommandText = "SELECT unique_id, directory, filename, last_mtime, last_attrtime, filter_name, filter_version " +
 				"FROM file_attributes WHERE directory= dir AND filename= fname";
-			InsertCommand = new SqliteCommand(this.connection);
+			InsertCommand = new SqliteCommand (this.connection);
 			InsertCommand.CommandText = "INSERT OR REPLACE INTO file_attributes " +
 							" (unique_id, directory, filename, last_mtime, last_attrtime, filter_name, filter_version) " +
 							" VALUES (@unique_id, @directory, @filename, @last_mtime, @last_attrtime, @filter_name, @filter_version)";
-			DeleteCommand = new SqliteCommand(this.connection);
+			DeleteCommand = new SqliteCommand (this.connection);
 			DeleteCommand.CommandText = "DELETE FROM file_attributes WHERE directory= directory AND filename= filename";
 		}
 
@@ -258,7 +258,6 @@
 			if (path != null && path != "/" && path.EndsWith ("/"))
 				path = path.TrimEnd ('/');
 
-			//SqliteCommand command;
 			SqliteDataReader reader;
 
 			if (! GetPathFlag (path))
@@ -271,9 +270,6 @@
 			string directory = FileSystem.GetDirectoryNameRootOk (path).Replace ("'", "''");
 			string filename = Path.GetFileName (path).Replace ("'", "''");
 			lock (connection) {
-				//command = SqliteUtils.QueryCommand (connection,
-								 //   "directory='{0}' AND filename='{1}'",
-								//    directory, filename);
 				ReadCommand.Parameters.AddWithValue ("@dir",directory);
 				ReadCommand.Parameters.AddWithValue ("@fname",filename);
 				reader = SqliteUtils.ExecuteReaderOrWait (ReadCommand);
@@ -282,7 +278,6 @@
 					attr = GetFromReader (reader);
 					
 				reader.Close ();
-				//command.Dispose ();
 			}
 
 			return attr;
@@ -305,7 +300,7 @@
 				if (filter_name == null)
 					filter_name = "";
 				filter_name = filter_name.Replace ("'", "''");
-				string[] param= new string [] {"@unique_id", "@directory", "@filename", "@last_mtime", "@last_attrtime", "@filter_name", "@filter_version"};
+				string[] param= new string [] { "@unique_id", "@directory", "@filename", "@last_mtime", "@last_attrtime", "@filter_name", "@filter_version"};
 				object[] vals =	new object [] {
 								GuidFu.ToShortString (fa.UniqueId),
 								fa.Directory.Replace ("'", "''"), fa.Filename.Replace ("'", "''"),
@@ -313,9 +308,9 @@
 								StringFu.DateTimeToString (fa.LastAttrTime),
 								filter_name,
 								fa.FilterVersion};
-				for (int i=0; i<param.Length; i++){
+				for (int i=0; i < param.Length; i++)
 					InsertCommand.Parameters.AddWithValue (param[i], vals[i]);
-				}
+				
 				ret = SqliteUtils.DoNonQuery (InsertCommand);
 				
 			}

Modified: trunk/beagle/beagled/SqliteUtils.cs
==============================================================================
--- trunk/beagle/beagled/SqliteUtils.cs	(original)
+++ trunk/beagle/beagled/SqliteUtils.cs	Sat Jan 19 07:23:37 2008
@@ -72,33 +72,23 @@
 			return DoNonQuery (connection, command_text, null, null);
 		}
 
-		public static int DoNonQuery ( SqliteCommand command)
+		public static int DoNonQuery (SqliteCommand command)
 		{
 			int ret = 0;
 			while (true) {
-					try {
-						ret = command.ExecuteNonQuery ();
-						break;
-					} catch (SqliteBusyException ex) {
-						Thread.Sleep (50);
-					} catch (Exception e) {
-						Log.Error (e, "SQL that caused the exception: {0}",command.CommandText);
-						throw;
-					}
+				try {
+					ret = command.ExecuteNonQuery ();
+					break;
+				} catch (SqliteBusyException ex) {
+					Thread.Sleep (50);
+				} catch (Exception e) {
+					Log.Error ( e, "SQL that caused the exception: {0}", command.CommandText);
+					throw;
 				}
+			}
 			return ret;
 		}
-		public static SqliteCommand QueryCommand (SqliteConnection connection, string where_format, params object [] where_args)
-		{
-			SqliteCommand command;
-			command = new SqliteCommand ();
-			command.Connection = connection;
-			command.CommandText =
-				"SELECT unique_id, directory, filename, last_mtime, last_attrtime, filter_name, filter_version " +
-				"FROM file_attributes WHERE " + 
-				String.Format (where_format, where_args);
-			return command;
-		}
+		
 
 		public static SqliteDataReader ExecuteReaderOrWait (SqliteCommand command)
 		{

Modified: trunk/beagle/beagled/TextCache.cs
==============================================================================
--- trunk/beagle/beagled/TextCache.cs	(original)
+++ trunk/beagle/beagled/TextCache.cs	Sat Jan 19 07:23:37 2008
@@ -173,17 +173,15 @@
 		}
 
 		private void initCommands(){
-			InsertCommand = new SqliteCommand(this.connection);
+			InsertCommand = new SqliteCommand (this.connection);
 			InsertCommand.CommandText = "INSERT OR REPLACE INTO textcache_data (uri, filename, data) VALUES (@uri,@filename,@data)";
-			LookupPathCommand = new SqliteCommand(this.connection);
+			LookupPathCommand = new SqliteCommand (this.connection);
 			LookupPathCommand.CommandText = "SELECT filename FROM textcache_data WHERE uri= uri";
-			LookupDataCommand = new SqliteCommand(this.connection);
+			LookupDataCommand = new SqliteCommand (this.connection);
 			LookupDataCommand.CommandText = "SELECT filename, data FROM textcache_data WHERE uri= uri";
-			DeleteCommand = new SqliteCommand(this.connection);
+			DeleteCommand = new SqliteCommand (this.connection);
 			DeleteCommand.CommandText = "DELETE FROM textcache_data WHERE uri= uri";
-			//InsertCommand.Parameters.Add("uri");
-			//InsertCommand.Parameters.Add("filename");
-			//InsertCommand.Parameters.Add("data");
+
 			
 		}
 		private SqliteConnection Open (string db_filename)
@@ -212,14 +210,11 @@
 		{
 			lock (connection) {
 				MaybeStartTransaction_Unlocked ();
-				InsertCommand.Parameters.AddWithValue("@uri",UriToString (uri));
-				InsertCommand.Parameters.AddWithValue("@filename",filename);
-				InsertCommand.Parameters.AddWithValue("@data", data);
+				InsertCommand.Parameters.AddWithValue ("@uri",UriToString (uri));
+				InsertCommand.Parameters.AddWithValue ("@filename",filename);
+				InsertCommand.Parameters.AddWithValue ("@data", data);
 				SqliteUtils.DoNonQuery (InsertCommand);
-//				SqliteUtils.DoNonQuery (connection,
-//							"INSERT OR REPLACE INTO textcache_data (uri, filename, data) VALUES (@uri,@filename,@data)",
-//							new string [] {"@uri", "@filename", "@data"},
-//							new object [] {UriToString (uri), filename, data});
+
 			}
 		}
 
@@ -235,14 +230,12 @@
 			//SqliteCommand command;
 			SqliteDataReader reader = null;
 			string path = null;
-			LookupPathCommand.Parameters.AddWithValue("@uri", UriToString(uri));
-			//command = NewCommand ("SELECT filename FROM textcache_data WHERE uri='{0}'", 
-			//                     UriToString (uri));
+			LookupPathCommand.Parameters.AddWithValue ("@uri", UriToString (uri));
 			reader = SqliteUtils.ExecuteReaderOrWait (LookupPathCommand);
 			if (SqliteUtils.ReadOrWait (reader))
 				path = reader.GetString (0);
 			reader.Close ();
-			//command.Dispose ();
+
 			
 			return path;
 		}
@@ -463,14 +456,12 @@
 		// If self_cache is true when called, then self_cache will be set upon return
 		public TextReader GetReader (Uri uri, ref bool self_cache)
 		{
-			//SqliteCommand command;
 			SqliteDataReader reader = null;
 			byte[] blob = null;
 			string filename = null;
 
 			lock (connection) {
-				//command = NewCommand ("SELECT filename, data FROM textcache_data WHERE uri='{0}'", 
-				//                      UriToString (uri));
+				
 				LookupDataCommand.Parameters.AddWithValue("@uri",UriToString (uri));
 				reader = SqliteUtils.ExecuteReaderOrWait (LookupDataCommand);
 				if (! SqliteUtils.ReadOrWait (reader)) {
@@ -483,7 +474,7 @@
 				if (! reader.IsDBNull (1))
 					blob = reader.GetValue (1) as byte [];
 				reader.Close ();
-				//command.Dispose ();
+
 			}
 
 			if (filename == SELF_CACHE_TAG) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]