tracker r2363 - in trunk: . data/db src/libtracker-common src/libtracker-db src/tracker-indexer src/trackerd



Author: mr
Date: Mon Oct 13 18:15:54 2008
New Revision: 2363
URL: http://svn.gnome.org/viewvc/tracker?rev=2363&view=rev

Log:
	* data/db/sqlite-stored-procs.sql: Completely reworked this file
	and removed about 50% of it. This 50% was unused stored
	procedures.

	* src/libtracker-common/tracker-file-utils.c:
	(tracker_file_get_mime_type): If stat() fails, just make that a
	normal message for now, not a warning, we should expect it.

	* src/libtracker-db/tracker-db-interface-sqlite.c: Added a few
	debug commands to see what is happening. 

	* src/libtracker-db/tracker-db-manager.c: (load_prepared_queries):
	Improved this function to actually allow for bracketed comments in
	the .sql files.

	* src/tracker-indexer/tracker-indexer-db.[ch]: 
	* src/tracker-indexer/tracker-indexer.ch: Added a function to
	recursively delete a path, this is needed for when a memory card
	is removed.

	* src/trackerd/tracker-db.c: Removed the stat() on every file that
	is returned if we are running a detailed search. This is
	unnecessary and causes a difference in the results returned if the
	database is inaccurate (which it shouldn't be).

	* src/trackerd/tracker-processor.c: (mount_point_removed_cb): When
	we unmount, add the directory to the deleted queue to be processed
	by the indexer for now. This needs to be fixed properly at some
	point (i.e. just disabling the items in the database, awaiting
	SQLite FTS for that).


Modified:
   trunk/ChangeLog
   trunk/data/db/sqlite-stored-procs.sql
   trunk/src/libtracker-common/tracker-file-utils.c
   trunk/src/libtracker-db/tracker-db-interface-sqlite.c
   trunk/src/libtracker-db/tracker-db-manager.c
   trunk/src/tracker-indexer/tracker-indexer-db.c
   trunk/src/tracker-indexer/tracker-indexer-db.h
   trunk/src/tracker-indexer/tracker-indexer.c
   trunk/src/trackerd/tracker-db.c
   trunk/src/trackerd/tracker-processor.c

Modified: trunk/data/db/sqlite-stored-procs.sql
==============================================================================
--- trunk/data/db/sqlite-stored-procs.sql	(original)
+++ trunk/data/db/sqlite-stored-procs.sql	Mon Oct 13 18:15:54 2008
@@ -1,235 +1,168 @@
+/*
+ * This file is dedicated to stored procedures 
+ */
+
+
+/*
+ * Metadata queries
+ */
+GetApplicationByID             SELECT DISTINCT (S.Path || '/' || S.Name) AS uri, 'Applications', 'Application', S.KeyMetadata1, S.KeyMetadata2, S.KeyMetadata3 FROM Services S WHERE S.ID = ?;
+GetAllServices                 SELECT TypeID, TypeName, Parent, PropertyPrefix, Enabled, Embedded, HasMetadata, HasFullText, HasThumbs, ContentMetadata, Database, ShowServiceFiles, ShowServiceDirectories, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6, KeyMetadata7, KeyMetadata8, KeyMetadata9, KeyMetadata10, KeyMetadata11 FROM ServiceTypes;
+GetEmailByID                   SELECT DISTINCT (S.Path || '/' || S.Name) AS uri, 'Emails', S.Mime, S.KeyMetadata1, S.KeyMetadata2, S.KeyMetadata3 FROM Services S WHERE S.ID = ?;
+GetFileByID                    SELECT DISTINCT Path, Name, Mime, ServiceTypeID FROM Services WHERE ID = ? AND Enabled = 1;
+GetFileByID2                   SELECT DISTINCT (Path || '/' || Name) AS uri, GetServiceName (ServiceTypeID), Mime FROM Services WHERE ID = ? AND Enabled = 1;
+GetFileMTime                   SELECT M.MetaDataValue FROM Services F inner join ServiceNumericMetaData M ON F.ID = M.ServiceID WHERE F.Path = ? AND F.Name = ? AND M.MetaDataID = (SELECT ID FROM MetaDataTypes WHERE MetaName ='File:Modified');
+GetServices                    SELECT TypeName, Description, Parent FROM ServiceTypes ORDER BY TypeID;
+
+/*
+ * Live search queries
+ */
+CreateEvent                    INSERT INTO Events (ServiceID, EventType) VALUES (?,?); 
+
+GetLiveSearchAllIDs            SELECT X.ServiceID FROM cache.LiveSearches AS X WHERE X.SearchID = ?
+GetLiveSearchDeletedIDs        SELECT E.ServiceID FROM Events AS E, cache.LiveSearches AS X WHERE E.ServiceID = X.ServiceID AND X.SearchID = ? AND E.EventType = 'Delete';
+GetLiveSearchHitCount          SELECT count(*) FROM cache.LiveSearches WHERE SearchID = ?;
+
+DeleteLiveSearchDeletedIDs     DELETE FROM cache.LiveSearches AS Y WHERE Y.ServiceID IN SELECT ServiceID FROM Events AS E, cache.LiveSearches AS X WHERE E.ServiceID = X.ServiceID AND X.SearchID = ? AND E.EventType = 'Delete'
+
+LiveSearchStopSearch           DELETE FROM cache.LiveSearches WHERE SearchID = ?
+
+/*
+ * Option queries
+ */
+GetOption                      SELECT OptionValue FROM Options WHERE OptionKey = ?;
+SetOption                      REPLACE INTO Options (OptionKey, OptionValue) VALUES (?,?);
+
+/*
+ * File queries
+ */
+CreateService                  INSERT INTO Services (ID, Path, Name, ServiceTypeID, Mime, Size, IsDirectory, IsLink, Offset, IndexTime, AuxilaryID) VALUES (?,?,?,?,?,?,?,?,?,?,?); 
+
+MoveService                    UPDATE Services SET Path = ?, Name = ? WHERE Path = ? AND Name = ?;
+MoveServiceChildren            UPDATE Services SET Path = replace (Path, ?, ?);
+
+SelectFileChild                SELECT ID, Path, Name, IsDirectory FROM Services WHERE Path = ?;
+
+DeleteContent                  DELETE FROM ServiceContents WHERE ServiceID = ? AND MetadataId = ?;
+DeleteService1                 DELETE FROM Services WHERE ID = ?;
+DeleteServiceRecursively       DELETE FROM Services WHERE Path = ? OR Path LIKE ?;
+DeleteServiceMetadata          DELETE FROM ServiceMetaData WHERE ServiceID = ?;
+DeleteServiceKeywordMetadata   DELETE FROM ServiceMetaData WHERE ServiceID = ?;
+DeleteServiceNumericMetadata   DELETE FROM ServiceMetaData WHERE ServiceID = ?;
+
+GetServiceID                   SELECT ID, IndexTime, IsDirectory, ServiceTypeID FROM Services WHERE Path = ? AND Name = ?;
+GetByServiceType               SELECT DISTINCT F.Path || '/' || F.Name AS uri FROM Services F WHERE F.ServiceTypeID IN (SELECT TypeId FROM ServiceTypes WHERE TypeName = ? OR Parent = ?) LIMIT ?,?;
+GetContents                    SELECT uncompress (Content) FROM ServiceContents WHERE ServiceID = ? AND MetadataID = ? AND Content is not null;
+GetFileContents                SELECT substr(uncompress (Content), ?, ?) FROM ServiceContents WHERE ServiceID = ?;
+GetAllContents                 SELECT uncompress (Content) FROM ServiceContents WHERE ServiceID = ? AND Content is not null;
+GetKeywordList                 SELECT DISTINCT K.MetaDataValue, count(*) AS totalcount FROM Services S, ServiceKeywordMetaData K WHERE K.ServiceID = S.ID AND (S.ServiceTypeID IN (SELECT TypeId FROM ServiceTypes WHERE TypeName = ? OR Parent = ?)) AND K.MetaDataId = 19 GROUP BY K.MetaDataValue ORDER BY totalcount desc, K.MetaDataValue ASC;
+
+SaveServiceContents            REPLACE INTO ServiceContents (ServiceID, MetadataID, Content) VALUES (?,?,compress (?));
+
+/*
+ * Metadata/MIME queries
+ */
+GetAllMetadata                 SELECT MetadataID, MetadataDisplay FROM ServiceMetadata WHERE ServiceID = ? UNION SELECT MetadataID, MetadataValue FROM ServiceKeywordMetadata WHERE ServiceID = ? UNION SELECT MetadataID, upper(MetadataValue) FROM ServiceNumericMetadata WHERE ServiceID = ?;
+GetMetadata                    SELECT MetaDataDisplay FROM ServiceMetaData WHERE ServiceID = ? AND MetaDataID = ?;
+GetMetadataAliases             SELECT DISTINCT M.MetaName, M.ID FROM MetaDataTypes M, MetaDataChildren C WHERE M.ID = C.ChildID AND C.MetaDataID = ?; 
+GetMetadataAliasesForName      SELECT DISTINCT M.MetaName, M.ID FROM MetaDataTypes M, MetaDataChildren C WHERE M.ID = C.ChildID AND C.MetaDataID = (SELECT ID FROM MetaDataTypes WHERE MetaName = ?) UNION SELECT M.MetaName, M.ID FROM MetaDataTypes M WHERE M.MetaName = ?; 
+GetMetadataIDValue             SELECT MetadataID, MetadataValue FROM ServiceMetadata WHERE ServiceID = ? ORDER BY MetadataID
+GetMetadataIDValueKeyword      SELECT MetadataID, MetadataValue FROM ServiceKeywordMetadata WHERE ServiceID = ? ORDER BY MetadataID
+GetMetadataIDValueNumeric      SELECT MetadataID, MetadataValue FROM ServiceNumericMetadata WHERE ServiceID = ? ORDER BY MetadataID
+GetMetadataKeyword             SELECT MetaDataValue FROM ServiceKeywordMetaData WHERE ServiceID = ? AND MetaDataID = ?;
+GetMetadataNumeric             SELECT MetaDataValue FROM ServiceNumericMetaData WHERE ServiceID = ? AND MetaDataID = ?;
+GetMetadataTypes               SELECT ID, MetaName, DataTypeID, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM MetaDataTypes;
+
+SetMetadata                    INSERT INTO ServiceMetaData (ServiceID, MetaDataID, MetaDataValue, MetaDataDisplay) VALUES (?,?,?,?);
+SetMetadataKeyword             INSERT INTO ServiceKeywordMetaData (ServiceID, MetaDataID, MetaDataValue) VALUES (?,?,?);
+SetMetadataNumeric             INSERT INTO ServiceNumericMetaData (ServiceID, MetaDataID, MetaDataValue) VALUES (?,?,?);
+
+DeleteMetadata                 DELETE FROM ServiceMetaData WHERE ServiceID = ? AND MetaDataID=?;
+DeleteMetadataKeyword          DELETE FROM ServiceKeywordMetaData WHERE ServiceID = ? AND MetaDataID=?;
+DeleteMetadataKeywordValue     DELETE FROM ServiceKeywordMetaData WHERE ServiceID = ? AND MetaDataID=? AND MetaDataValue = ?;DeleteMetadataValue DELETE FROM ServiceMetaData WHERE ServiceID = ? AND MetaDataID=? AND MetaDataDisplay=?;
+DeleteMetadataNumeric          DELETE FROM ServiceNumericMetaData WHERE ServiceID = ? AND MetaDataID=?;
+
+InsertMetaDataChildren         INSERT INTO MetaDataChildren (ChildID,MetadataID) VALUES (?,(SELECT ID FROM MetaDataTypes WHERE MetaName = ?));
+InsertMetadataType             INSERT INTO MetaDataTypes (MetaName) VALUES (?);
+InsertMimePrefixes             REPLACE INTO FileMimePrefixes (MimePrefix) VALUES (?);
+InsertMimes                    REPLACE INTO FileMimes (Mime) VALUES (?);
+InsertServiceTabularMetadata   REPLACE INTO ServiceTabularMetadata (ServiceTypeID, MetaName) VALUES (?, ?);
+InsertServiceTileMetadata      REPLACE INTO ServiceTileMetadata (ServiceTypeID, MetaName) VALUES (?, ?);
+InsertServiceType              REPLACE INTO ServiceTypes (TypeName) VALUES (?);
+
+GetMimeForServiceId            SELECT Mime FROM FileMimes WHERE ServiceTypeId = ?;
+GetMimePrefixForServiceId      SELECT MimePrefix FROM FileMimePrefixes WHERE ServiceTypeId = ?;
+
+/* 
+ * Pending files queries - currently unused 
+ */
+ExistsPendingFiles             SELECT count (*) FROM FilePending WHERE Action <> 20;
+InsertPendingFile              INSERT INTO FilePending (FileID, Action, PendingDate, FileUri, MimeType, IsDir, IsNew, RefreshEmbedded, RefreshContents, ServiceTypeID) VALUES (?,?,?,?,?,?,?,?,?,?);
+CountPendingMetadataFiles      SELECT count (*) FROM FilePending WHERE Action = 20;
+SelectPendingByUri             SELECT FileID, FileUri, Action, MimeType, IsDir, IsNew, RefreshEmbedded, RefreshContents, ServiceTypeID FROM FilePending WHERE FileUri = ?;
+UpdatePendingFile              UPDATE FilePending SET PendingDate = ?, Action = ? WHERE FileUri = ?;
+DeletePendingFile              DELETE FROM FilePending WHERE FileUri = ?;
+
+/* 
+ * Watch queries - currently unused
+ */
+GetWatchUri                    SELECT URI FROM FileWatches WHERE WatchID = ?;
+GetWatchID                     SELECT WatchID FROM FileWatches WHERE URI = ?;
+GetSubWatches                  SELECT WatchID FROM FileWatches WHERE URI glob ?;
+DeleteWatch                    DELETE FROM FileWatches WHERE URI = ?;
+DeleteSubWatches               DELETE FROM FileWatches WHERE URI glob ?;
+InsertWatch                    INSERT INTO FileWatches (URI, WatchID) VALUES (?,?);
+
+/*
+ * Search result queries
+ */
+InsertSearchResult1            INSERT INTO SearchResults1 (SID, Score) VALUES (?,?);
+DeleteSearchResults1           DELETE FROM SearchResults1;
+
+/*
+ * Statistics queries
+ */
+IncStat                        UPDATE ServiceTypes SET TypeCount = (TypeCount + 1) WHERE TypeName = ?;
+DecStat                        UPDATE ServiceTypes SET TypeCount = (TypeCount - 1) WHERE TypeName = ?;
+GetStats                       SELECT TypeName, TypeCount FROM ServiceTypes GROUP BY TypeName ORDER BY TypeID ASC;
+
+GetHitDetails                  SELECT ROWID, HitCount, HitArraySize FROM HitIndex WHERE word = ?;
+
+/*
+ * XESAM queries
+ */
+InsertXesamMetadataType        INSERT INTO XesamMetaDataTypes (MetaName) VALUES (?);
+InsertXesamServiceType         INSERT INTO XesamServiceTypes (TypeName) VALUES (?);
+InsertXesamMetaDataMapping     INSERT INTO XesamMetaDataMapping (XesamMetaName, MetaName) VALUES (?, ?);
+InsertXesamServiceMapping      INSERT INTO XesamServiceMapping (XesamTypeName, TypeName) VALUES (?, ?);
+InsertXesamServiceLookup       REPLACE INTO XesamServiceLookup (XesamTypeName, TypeName) VALUES (?, ?);
+InsertXesamMetaDataLookup      REPLACE INTO XesamMetaDataLookup (XesamMetaName, MetaName) VALUES (?, ?);
+
+GetXesamServiceParents         SELECT TypeName, Parents FROM XesamServiceTypes;
+GetXesamServiceChildren        SELECT Child FROM XesamServiceChildren WHERE Parent = ?;
+GetXesamServiceMappings        SELECT TypeName FROM XesamServiceMapping WHERE XesamTypeName = ?;
+GetXesamServiceLookups         SELECT DISTINCT TypeName FROM XesamServiceLookup WHERE XesamTypeName = ?;
+
+GetXesamMetaDataParents        SELECT MetaName, Parents FROM XesamMetaDataTypes;
+GetXesamMetaDataChildren       SELECT Child FROM XesamMetaDataChildren WHERE Parent = ?;
+GetXesamMetaDataMappings       SELECT MetaName FROM XesamMetaDataMapping WHERE XesamMetaName = ?;
+GetXesamMetaDataLookups        SELECT DISTINCT MetaName FROM XesamMetaDataLookup WHERE XesamMetaName = ?;
+GetXesamMetaDataTextLookups    SELECT DISTINCT L.MetaName FROM XesamMetaDataLookup L INNER JOIN XesamMetaDataTypes T ON (T.MetaName = L.XesamMetaName) WHERE T.DataTypeID = 3;
+
+GetXesamMetaDataTypes          SELECT ID, MetaName, DataTypeID, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM XesamMetaDataTypes;
+GetXesamServiceTypes           SELECT TypeID, TypeName, Parents, PropertyPrefix, Enabled, Embedded, HasMetadata, HasFullText, HasThumbs, ContentMetadata, Database, ShowServiceFiles, ShowServiceDirectories, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6, KeyMetadata7, KeyMetadata8, KeyMetadata9, KeyMetadata10, KeyMetadata11 FROM XesamServiceTypes;
+
+InsertXesamMimes               REPLACE INTO XesamFileMimes (Mime) VALUES (?);
+InsertXesamMimePrefixes        REPLACE INTO XesamFileMimePrefixes (MimePrefix) VALUES (?);
+
+GetXesamMimeForServiceId       SELECT Mime FROM XesamFileMimes WHERE ServiceTypeId = ?;
+GetXesamMimePrefixForServiceId SELECT MimePrefix FROM XesamFileMimePrefixes WHERE ServiceTypeId = ?;
+
+/*
+ * Deprecated
+ */
+GetNewID                       SELECT OptionValue FROM Options WHERE OptionKey = 'Sequence';
+UpdateNewID                    UPDATE Options SET OptionValue = ? WHERE OptionKey = 'Sequence';
 
-GetMetaDataTypeID select ID From MetaDataTypes where MetaName = ?;
-
-GetMetaDataType select DataTypeID From MetaDataTypes where MetaName = ?;
-
-GetRelatedServiceIDs select TypeId from ServiceTypes where TypeName = ? or Parent = ?;
-
-GetFileByID  SELECT  DISTINCT Path , Name, Mime, ServiceTypeID  FROM Services WHERE ID = ? and Enabled = 1;
-
-GetFileByID2  SELECT DISTINCT (Path || '/' || Name) as uri, GetServiceName (ServiceTypeID), Mime FROM Services WHERE ID = ? and Enabled = 1;
-
-GetFileByID3  SELECT  DISTINCT Path , Name, Mime, ServiceTypeID  FROM Services WHERE ID = ?;
-
-GetEmailByID2  SELECT DISTINCT (S.Path || '/' || S.Name) as uri, 'Emails', S.Mime, M1.MetaDataDisplay, M2.MetaDataDisplay FROM Services S Left Outer Join ServiceMetaData M1 on S.ID = M1.ServiceID and M1.MetaDataID = (select ID From MetaDataTypes where MetaName ='Email:Subject') Left Outer Join ServiceMetaData M2 on S.ID = M2.ServiceID and M2.MetaDataID = (select ID From MetaDataTypes where MetaName ='Email:Sender') WHERE S.ID = ?;
-
-GetEmailByID  SELECT DISTINCT (S.Path || '/' || S.Name) as uri, 'Emails', S.Mime, S.KeyMetadata1, S.KeyMetadata2, S.KeyMetadata3 FROM Services S  WHERE S.ID = ?;
-
-GetApplicationByID  SELECT DISTINCT (S.Path || '/' || S.Name) as uri, 'Applications', 'Application', S.KeyMetadata1, S.KeyMetadata2, S.KeyMetadata3 FROM Services S  WHERE S.ID = ?;
-
-GetFileMTime SELECT M.MetaDataValue  FROM Services F inner join ServiceNumericMetaData M on F.ID = M.ServiceID WHERE F.Path = ? and F.Name = ? and M.MetaDataID = (select ID From MetaDataTypes where MetaName ='File:Modified');
-
-GetServices SELECT TypeName, Description, Parent  FROM ServiceTypes ORDER BY TypeID;
-GetAllServices SELECT TypeID, TypeName, Parent, PropertyPrefix, Enabled, Embedded, HasMetadata, HasFullText, HasThumbs, ContentMetadata, Database, ShowServiceFiles, ShowServiceDirectories, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6, KeyMetadata7, KeyMetadata8, KeyMetadata9, KeyMetadata10, KeyMetadata11  FROM ServiceTypes;
-
-# GetNewID and UpdateNewID are deprecated !!
-GetNewID SELECT OptionValue FROM Options WHERE OptionKey = 'Sequence';
-UpdateNewID UPDATE Options set OptionValue = ? WHERE OptionKey = 'Sequence';
-CreateEvent INSERT INTO Events (ServiceID, EventType) VALUES (?,?); 
-GetEvents SELECT ID, ServiceID, EventType FROM Events WHERE BeingHandled = 1;
-SetEventsBeingHandled UPDATE Events SET BeingHandled = 1;
-
-GetLiveSearchAllIDs SELECT X.ServiceID FROM cache.LiveSearches AS X WHERE X.SearchID = ?
-GetLiveSearchDeletedIDs SELECT E.ServiceID FROM Events as E, cache.LiveSearches as X WHERE E.ServiceID = X.ServiceID AND X.SearchID = ? AND E.EventType = 'Delete';
-DeleteLiveSearchDeletedIDs DELETE FROM cache.LiveSearches AS Y WHERE Y.ServiceID IN SELECT ServiceID FROM Events as E, cache.LiveSearches as X WHERE E.ServiceID = X.ServiceID AND X.SearchID = ? AND E.EventType = 'Delete'
-
-GetLiveSearchHitCount SELECT count(*) FROM cache.LiveSearches WHERE SearchID = ?;
-LiveSearchStopSearch DELETE FROM cache.LiveSearches WHERE SearchID = ?
-
-# GetNewEventID and UpdateNewEventID are deprecated !!
-GetNewEventID SELECT OptionValue FROM Options WHERE OptionKey = 'EventSequence';
-UpdateNewEventID UPDATE Options set OptionValue = ? WHERE OptionKey = 'EventSequence';
-
-GetUpdateCount SELECT OptionValue FROM Options WHERE OptionKey = 'UpdateCount';
-SetUpdateCount UPDATE Options set OptionValue = ?  WHERE OptionKey = 'UpdateCount';
-
-GetOption SELECT OptionValue FROM Options WHERE OptionKey = ?;
-SetOption REPLACE into Options (OptionKey, OptionValue) values (?,?);
-
-CreateService INSERT INTO Services (ID, Path, Name, ServiceTypeID, Mime, Size, IsDirectory, IsLink, Offset, IndexTime, AuxilaryID) VALUES (?,?,?,?,?,?,?,?,?,?,?); 
-
-MoveService UPDATE Services SET Path = ?, Name = ? WHERE Path = ? AND Name = ?;
-MoveServiceChildren UPDATE Services SET Path = replace (Path, ?, ?);
-
-GetServiceID SELECT ID, IndexTime, IsDirectory, ServiceTypeID FROM Services WHERE Path = ? AND Name = ?;
-
-SelectFileChild SELECT ID, Path, Name, IsDirectory  FROM Services WHERE Path = ?;
-
-SelectFileChildWithoutDirs SELECT Path, Name  FROM Services WHERE Path = ? and IsDirectory = 0;
-
-SelectFileSubFolders SELECT ID, Path, Name, IsDirectory FROM Services WHERE (Path = ?  or Path glob ?) And IsDirectory = 1;
-
-SelectSubFileIDs SELECT ID FROM Services WHERE (Path = ?  or Path glob ?);
-
-UpdateFile UPDATE Services SET ServiceTypeID=?, Path=?, Name=?, Mime=?, Size=?, IndexTime =?, Offset=? WHERE ID = ?; 
-UpdateFileMTime UPDATE Services SET IndexTime=? where Path = ? and Name = ?;
-UpdateFileMove 	UPDATE Services SET Path = ?, Name = ? WHERE ID = ?;
-UpdateFileMoveChild UPDATE Services SET Path = ? WHERE Path = ?; 
-
-DeleteService1 Delete FROM Services Where (ID = ?);
-DeleteService2 Delete FROM Services Where (Path = ?);
-DeleteService3 Delete FROM Services Where (Path glob ?);
-DeleteService4 Delete FROM BackupServices Where (Path = ?);
-DeleteService5 Delete FROM BackupServices Where (Path glob ?);
-DeleteService6 Delete FROM BackupServices Where (Path = ? and Name = ?);
-DeleteService7 Delete FROM ServiceLinks Where (SourcePath = ? and SourceName = ?);
-DeleteService8 Delete FROM ServiceLinks Where (SourcePath = ?) or (SourcePath glob ?);
-DeleteService9 Delete FROM ServiceLinks Where (DestPath = ? and DestName = ?);
-DeleteService10 Delete FROM ServiceLinks Where (DestPath = ?) or (DestPath glob ?); 
-DeleteService11 DELETE FROM ServiceContents where ServiceID = ?;
-
-DeleteServiceMetadata DELETE FROM ServiceMetaData WHERE ServiceID = ?;
-DeleteServiceKeywordMetadata DELETE FROM ServiceMetaData WHERE ServiceID = ?;
-DeleteServiceNumericMetadata DELETE FROM ServiceMetaData WHERE ServiceID = ?;
-
-DeleteEmbeddedServiceMetadata1 DELETE FROM ServiceMetaData WHERE ServiceID = ? and MetaDataID in (select ID from MetaDataTypes where Embedded = 1);
-DeleteEmbeddedServiceMetadata2 DELETE FROM ServiceKeywordMetaData WHERE ServiceID = ? and MetaDataID in (select ID from MetaDataTypes where Embedded = 1);
-DeleteEmbeddedServiceMetadata3 DELETE FROM ServiceNumericMetaData WHERE ServiceID = ? and MetaDataID in (select ID from MetaDataTypes where Embedded = 1);
-
-GetByServiceType SELECT  DISTINCT F.Path || '/' || F.Name as uri  FROM Services F WHERE F.ServiceTypeID in (select TypeId from ServiceTypes where TypeName = ? or Parent = ?) LIMIT ?,?;
-
-SaveServiceContents REPLACE into ServiceContents (ServiceID, MetadataID, Content) values (?,?,compress (?));
-DeleteContent DELETE FROM ServiceContents where ServiceID = ? and MetadataId = ?;
-DeleteAllContents DELETE FROM ServiceContents where ServiceID = ?;
-GetContents Select uncompress (Content) from ServiceContents where ServiceID = ? and MetadataID = ? and Content is not null;
-GetFileContents Select substr(uncompress (Content), ?, ?) from ServiceContents where ServiceID = ?;
-GetAllContents Select uncompress (Content) from ServiceContents where ServiceID = ? and Content is not null;
-
-GetKeywordList Select distinct K.MetaDataValue, count(*) as totalcount from Services S, ServiceKeywordMetaData K where K.ServiceID = S.ID AND (S.ServiceTypeID in (select TypeId from ServiceTypes where TypeName = ? or Parent = ?)) AND  K.MetaDataId = 19 group by K.MetaDataValue order by totalcount desc, K.MetaDataValue asc;
-GetKeywords Select MetaDataValue from ServiceKeywordMetaData where ServiceID = (select ID From Services where Path = ? and Name  = ?) and MetaDataId in (select ChildID from MetaDataChildren where MetadataId = (select ID from MetadataTypes T where MetaName = 'DC:Keywords'));
-
-GetAllIndexable SELECT S.MetaDataValue as MetaValue, M.Weight, M.Filtered, M.Delimited  FROM ServiceMetaData S, MetaDataTypes M WHERE  S.MetaDataID = M.ID AND S.ServiceID = ? And S.MetaDataValue is not null and M.DatatypeID = 1 and M.Embedded >= ?;
-GetAllIndexableKeywords SELECT K.MetaDataValue as MetaValue, M.Weight, M.Filtered, M.Delimited as MetaWeight FROM ServiceKeywordMetaData K, MetaDataTypes M WHERE  K.MetaDataID = M.ID AND K.ServiceID = ? And K.MetaDataValue is not null and M.DatatypeID = 0 and M.Embedded >= ?;
-
-GetMetadataKeyword SELECT MetaDataValue FROM ServiceKeywordMetaData WHERE ServiceID = ? AND MetaDataID = ?;
-GetMetadata SELECT MetaDataDisplay FROM ServiceMetaData WHERE ServiceID = ? AND MetaDataID = ?;
-GetMetadataNumeric SELECT MetaDataValue FROM ServiceNumericMetaData WHERE ServiceID = ? AND MetaDataID = ?;
-
-GetMetadataIDValueKeyword SELECT MetadataID, MetadataValue FROM ServiceKeywordMetadata WHERE ServiceID = ? ORDER BY MetadataID
-GetMetadataIDValue SELECT MetadataID, MetadataValue FROM ServiceMetadata WHERE ServiceID = ? ORDER BY MetadataID
-GetMetadataIDValueNumeric SELECT MetadataID, MetadataValue FROM ServiceNumericMetadata WHERE ServiceID = ? ORDER BY MetadataID
-
-GetAllMetadata SELECT MetadataID, MetadataDisplay FROM ServiceMetadata WHERE ServiceID = ? UNION SELECT MetadataID, MetadataValue FROM ServiceKeywordMetadata WHERE ServiceID = ? UNION SELECT MetadataID, upper(MetadataValue) FROM ServiceNumericMetadata WHERE ServiceID = ?;
-
-SetMetadataKeyword INSERT INTO ServiceKeywordMetaData (ServiceID, MetaDataID, MetaDataValue) VALUES (?,?,?);
-SetMetadata INSERT INTO ServiceMetaData (ServiceID, MetaDataID, MetaDataValue, MetaDataDisplay) VALUES (?,?,?,?);
-SetMetadataNumeric INSERT INTO ServiceNumericMetaData (ServiceID, MetaDataID, MetaDataValue) VALUES (?,?,?);
-
-DeleteMetadataKeyword DELETE FROM ServiceKeywordMetaData where ServiceID = ? and  MetaDataID=?;
-DeleteMetadata DELETE FROM ServiceMetaData where ServiceID = ? and  MetaDataID=?;
-DeleteMetadataNumeric DELETE FROM ServiceNumericMetaData where ServiceID = ? and  MetaDataID=?;
-
-DeleteMetadataKeywordValue DELETE FROM ServiceKeywordMetaData where ServiceID = ? and  MetaDataID=? and MetaDataValue = ?;
-DeleteMetadataValue DELETE FROM ServiceMetaData where ServiceID = ? and  MetaDataID=? and MetaDataDisplay=?;
-DeleteMetadataNumericValue DELETE FROM ServiceNumericMetaData where ServiceID = ? and  MetaDataID=? and MetaDataValue=?;
-
-GetMetadataTypeInfo Select ID, MetaName, DataTypeID, DisplayName, Description, Enabled, UIVisible, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM MetaDataTypes where MetaName = ?;
-GetMetadataTypes SELECT ID, MetaName, DataTypeID, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM MetaDataTypes;
-GetMetadataTypeDetails SELECT ID, MetaName, DataTypeID, DisplayName, Description, Enabled, UIVisible, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM MetaDataTypes;
-GetMetadataTypesLike SELECT ID, MetaName, DataTypeID, DisplayName, Description, Enabled, UIVisible, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM MetaDataTypes WHERE MetaName glob ?;
-GetWriteableMetadataTypes SELECT ID, MetaName, DataTypeID, DisplayName, Description, Enabled, UIVisible, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM MetaDataTypes where Embedded = 0;
-GetWriteableMetadataTypesLike SELECT ID, MetaName, DataTypeID, DisplayName, Description, Enabled, UIVisible, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM MetaDataTypes WHERE MetaName glob ? and  Embedded = 0;
-
-InsertMetaDataChildren INSERT INTO  MetaDataChildren (ChildID,MetadataID) VALUES (?,(select ID from MetaDataTypes where MetaName = ?));
-GetMetadataAliases SELECT distinct M.MetaName, M.ID from MetaDataTypes M, MetaDataChildren C where M.ID = C.ChildID and C.MetaDataID = ?; 
-GetMetadataAliasesForName SELECT distinct M.MetaName, M.ID from MetaDataTypes M, MetaDataChildren C where M.ID = C.ChildID and C.MetaDataID = (select ID from MetaDataTypes where MetaName = ?) union select M.MetaName, M.ID from MetaDataTypes M where M.MetaName = ?; 
-
-SelectRegisteredClasses SELECT DISTINCT TypeName FROM ServiceTypes;
-
-InsertMetadataType INSERT INTO MetaDataTypes (MetaName) Values (?);
-
-InsertServiceType REPLACE INTO  ServiceTypes (TypeName) Values (?);
-InsertServiceTileMetadata REPLACE Into ServiceTileMetadata (ServiceTypeID, MetaName) VALUES (?, ?);
-InsertServiceTabularMetadata REPLACE Into ServiceTabularMetadata (ServiceTypeID, MetaName) VALUES (?, ?);
-
-GetServiceTypes select TypeID, TypeName, Parent, Enabled, Embedded, HasMetadata, HasFullText, HasThumbs, ContentMetadata, KeyMetadata1,  KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6, KeyMetadata7, KeyMetadata8, KeyMetadata9, KeyMetadata10, KeyMetadata11 From ServiceTypes;
-GetServiceTypeDetails select TypeID, TypeName, DisplayName, Parent, Enabled, Embedded, ChildResource, CreateDesktopFile, CanCopy, CanDelete, HasMetadata, HasFullText, HasThumbs, ContentMetadata, UIView, Description, Database, Icon, IndexerExec, ThumbExec, ViewerExec, UIVisible, UIMetadata1, UIMetadata2, UIMetadata3, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6 FROM ServiceTypes;
-GetServiceTypeDetailsByName select TypeID, TypeName, DisplayName, Parent, Enabled, Embedded, ChildResource, CreateDesktopFile, CanCopy, CanDelete, HasMetadata, HasFullText, HasThumbs, ContentMetadata, UIView, Description, Database, Icon, IndexerExec, ThumbExec, ViewerExec, UIVisible, UIMetadata1, UIMetadata2, UIMetadata3, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6 FROM ServiceTypes where TypeName = ?;
-GetServiceTypeDetailsByID select TypeId, TypeName, DisplayName, Parent, Enabled, Embedded, ChildResource, CreateDesktopFile, CanCopy, CanDelete, HasMetadata, HasFullText, HasThumbs, ContentMetadata, UIView, Description, Database, Icon, IndexerExec, ThumbExec, ViewerExec, UIVisible, UIMetadata1, UIMetadata2, UIMetadata3, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6 FROM ServiceTypes where TypeID = ?;
-GetServiceTile	select M.MetaName, M.ID from MetaDataTypes M where M.ID in (select MetadataTypeID  from ServiceTileMetadata where ServiceTypeID = ?);
-GetServiceTable select M.MetaName, M.ID from MetaDataTypes M where M.ID in (select MetadataTypeID  from ServiceTabularMetadata where ServiceTypeID = ?);
-
-InsertMimes replace into FileMimes (Mime) Values (?);
-InsertMimePrefixes replace into FileMimePrefixes (MimePrefix) Values (?);
-
-GetMimeForServiceId select Mime from FileMimes where ServiceTypeId = ?;
-GetMimePrefixForServiceId select MimePrefix from FileMimePrefixes where ServiceTypeId = ?;
-
-ExistsPendingFiles select count (*) from FilePending where Action <> 20;
-InsertPendingFile INSERT INTO FilePending (FileID, Action, PendingDate, FileUri, MimeType, IsDir, IsNew, RefreshEmbedded, RefreshContents, ServiceTypeID) VALUES (?,?,?,?,?,?,?,?,?,?);
-CountPendingMetadataFiles select count (*) from FilePending where Action = 20;
-SelectPendingByUri SELECT  FileID, FileUri, Action, MimeType, IsDir, IsNew, RefreshEmbedded, RefreshContents, ServiceTypeID FROM FilePending WHERE FileUri = ?;
-UpdatePendingFile UPDATE FilePending SET PendingDate = ?, Action = ? WHERE FileUri = ?;
-DeletePendingFile DELETE FROM FilePending WHERE FileUri = ?;
-
-GetWatchUri select URI from FileWatches where WatchID = ?;
-GetWatchID select WatchID from FileWatches where URI = ?;
-GetSubWatches select WatchID from FileWatches where URI glob ?;
-DeleteWatch delete from FileWatches where URI = ?;
-DeleteSubWatches delete from FileWatches where URI glob ?;
-InsertWatch insert into FileWatches (URI, WatchID) values (?,?);
-
-InsertSearchResult1 insert into SearchResults1 (SID, Score) values (?,?);
-DeleteSearchResults1 delete from SearchResults1;
-
-GetMboxes  select MailApp, MailType, Filename, Path, UriPrefix, Offset, LastOffset, MailCount, JunkCount, DeleteCount, Mtime  from MailSummary;
-GetMBoxDetails select MailApp, MailType, Filename, UriPrefix, Offset, LastOffset, MailCount, JunkCount, DeleteCount, Mtime  from MailSummary where path = ?;
-GetMboxID select ID from MailSummary where path = ?;
-GetMBoxPath select path from MailSummary where FileName = ?;
-InsertMboxDetails insert into MailSummary (MailApp, MailType, FileName, Path, UriPrefix, Offset, LastOffset, MailCount, JunkCount, DeleteCount, Mtime) values (?,?,?,?,?,0,0,0,0,0,0);
-UpdateMboxOffset update MailSummary set Offset = ? where Path = ?;
-UpdateMboxCounts update MailSummary set MailCount = ?, JunkCount = ?, DeleteCount = ? where Path = ?;
-
-SetJunkMbox update MailSummary set NeedsChecking = ? where path = ?;
-
-LookupJunk select SummaryID from JunkMail where UID = ? and SummaryID = ?;
-InsertJunk insert into JunkMail values (?,?);
-
-selectStats Select Sum(TypeCount) from ServiceTypes where TypeName = ? or TypeName in (select TypeName from ServiceTypes where Parent = ?);
-IncStat UPDATE ServiceTypes set TypeCount = (TypeCount + 1) where TypeName = ?;
-DecStat UPDATE ServiceTypes set TypeCount = (TypeCount - 1) where TypeName = ?;
-GetStats Select TypeName, TypeCount from ServiceTypes Group By TypeName order by TypeID asc;
-
-InsertBackupService INSERT INTO BackupServices (Path, Name) select S.Path, S.Name from Services S where S.ID = ?;
-UpdateBackupService Update BackupServices set Path = ? and Name = ? where Path = ? and Name = ?;
-GetBackupService Select ID from BackupServices where Path = ? and  Name = ?;
-GetBackupServiceByID Select B.ID from BackupServices B, Services S where B.Path = S.Path and  B.Name = S.Name and S.ID = ?;
-GetBackupMetadata select M.MetaName, B.UserValue from BackupMetadata B, MetadataTypes M, BackupServices BS where B.MetadataID = M.ID and B.ServiceID = BS.ID and BS.Path = ? and BS.Name = ?;
-SetBackupMetadata INSERT INTO BackupMetadata (ServiceID, MetadataID, UserValue) VALUES (?,?,?);
-DeleteBackupMetadataValue Delete From BackupMetadata where  ServiceID = ? and MetadataID = ? and UserValue = ?;
-DeleteBackupMetadata Delete From BackupMetadata where  ServiceID = ? and MetadataID = ?;
-
-GetWords Select word from HitIndex where word glob ?;
-GetWordBatch Select ROWID, word, HitCount, HitArraySize from HitIndex limit 100;
-GetHitDetails Select ROWID, HitCount, HitArraySize From HitIndex where word = ?;
-DeleteWord delete from HitIndex where ROWID = ?;
-InsertHitDetails Insert into HitIndex (Word, HitCount, HitArraySize, HitArray) Values (?,?,?, ZeroBlob(?));
-UpdateHitDetails Update HitIndex set HitCount = ?, HitArraySize = ? where ROWID = ?;
-ResizeHitDetails Update HitIndex set HitCount = ?, HitArraySize = ?, HitArray = Zeroblob(?) where ROWID = ?;
-
-InsertXesamMetadataType INSERT INTO XesamMetaDataTypes (MetaName) Values (?);
-InsertXesamServiceType INSERT INTO XesamServiceTypes (TypeName) Values (?);
-InsertXesamMetaDataMapping INSERT INTO XesamMetaDataMapping (XesamMetaName, MetaName) Values (?, ?);
-InsertXesamServiceMapping INSERT INTO XesamServiceMapping (XesamTypeName, TypeName) Values (?, ?);
-InsertXesamServiceLookup REPLACE INTO XesamServiceLookup (XesamTypeName, TypeName) Values (?, ?);
-InsertXesamMetaDataLookup REPLACE INTO XesamMetaDataLookup (XesamMetaName, MetaName) Values (?, ?);
-
-GetXesamServiceParents SELECT TypeName, Parents FROM XesamServiceTypes;
-GetXesamServiceChildren SELECT Child FROM XesamServiceChildren WHERE Parent = ?;
-GetXesamServiceMappings SELECT TypeName FROM XesamServiceMapping WHERE XesamTypeName = ?;
-GetXesamServiceLookups SELECT DISTINCT TypeName FROM XesamServiceLookup WHERE XesamTypeName = ?;
-
-GetXesamMetaDataParents SELECT MetaName, Parents FROM XesamMetaDataTypes;
-GetXesamMetaDataChildren SELECT Child FROM XesamMetaDataChildren WHERE Parent = ?;
-GetXesamMetaDataMappings SELECT MetaName FROM XesamMetaDataMapping WHERE XesamMetaName = ?;
-GetXesamMetaDataLookups SELECT DISTINCT MetaName FROM XesamMetaDataLookup WHERE XesamMetaName = ?;
-GetXesamMetaDataTextLookups SELECT DISTINCT L.MetaName FROM XesamMetaDataLookup L INNER JOIN XesamMetaDataTypes T ON (T.MetaName = L.XesamMetaName) WHERE T.DataTypeID = 3;
-
-GetXesamMetaDataTypes SELECT ID, MetaName, DataTypeID, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM XesamMetaDataTypes;
-GetXesamServiceTypes SELECT TypeID, TypeName, Parents, PropertyPrefix, Enabled, Embedded, HasMetadata, HasFullText, HasThumbs, ContentMetadata, Database, ShowServiceFiles, ShowServiceDirectories, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6, KeyMetadata7, KeyMetadata8, KeyMetadata9, KeyMetadata10, KeyMetadata11  FROM XesamServiceTypes;
-
-InsertXesamMimes replace into XesamFileMimes (Mime) Values (?);
-InsertXesamMimePrefixes replace into XesamFileMimePrefixes (MimePrefix) Values (?);
-
-GetXesamMimeForServiceId select Mime from XesamFileMimes where ServiceTypeId = ?;
-GetXesamMimePrefixForServiceId select MimePrefix from XesamFileMimePrefixes where ServiceTypeId = ?;
+GetNewEventID                  SELECT OptionValue FROM Options WHERE OptionKey = 'EventSequence';
+UpdateNewEventID               UPDATE Options SET OptionValue = ? WHERE OptionKey = 'EventSequence';

Modified: trunk/src/libtracker-common/tracker-file-utils.c
==============================================================================
--- trunk/src/libtracker-common/tracker-file-utils.c	(original)
+++ trunk/src/libtracker-common/tracker-file-utils.c	Mon Oct 13 18:15:54 2008
@@ -264,7 +264,7 @@
 				  &error);
 
 	if (G_UNLIKELY (error)) {
-		g_warning ("Could not guess mimetype, %s\n",
+		g_message ("Could not guess mimetype, %s\n",
 			   error->message);
 		g_error_free (error);
 		content_type = NULL;

Modified: trunk/src/libtracker-db/tracker-db-interface-sqlite.c
==============================================================================
--- trunk/src/libtracker-db/tracker-db-interface-sqlite.c	(original)
+++ trunk/src/libtracker-db/tracker-db-interface-sqlite.c	Mon Oct 13 18:15:54 2008
@@ -472,6 +472,7 @@
 			return NULL;
 		}
 
+                /* g_debug ("Running procedure: '%s'", procedure); */
 		result = sqlite3_prepare_v2 (priv->db, procedure, -1, &stmt, NULL);
 
 		if (result == SQLITE_OK && stmt) {
@@ -552,6 +553,7 @@
 
 	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (db_interface);
 
+        /* g_debug ("Running query: '%s'", query); */
 	retval = sqlite3_prepare_v2 (priv->db, query, -1, &stmt, NULL);
 
 	if (retval != SQLITE_OK) {

Modified: trunk/src/libtracker-db/tracker-db-manager.c
==============================================================================
--- trunk/src/libtracker-db/tracker-db-manager.c	(original)
+++ trunk/src/libtracker-db/tracker-db-manager.c	Mon Oct 13 18:15:54 2008
@@ -20,8 +20,8 @@
 
 #include "config.h"
 
-#include <stdlib.h>
 #include <string.h>
+#include <stdlib.h>
 #include <regex.h>
 #include <zlib.h>
 
@@ -922,21 +922,79 @@
 
 	if (queries) {
 		GStrv p;
+		gchar *start;
+		gchar *end;
+
+		start = NULL;
+		end = NULL;
 
 		for (p = queries; *p; p++) {
-			GStrv details;
+			GStrv        details;
+			gchar       *line;
+			const gchar *str;
+
+			line = NULL;
+
+			/* Check for comments */
+			if (start) {
+				if ((str = strstr (*p, "*/")) != NULL) {
+					str += 2;
+					end = g_strndup (str, strlen (*p) - strlen (str));
+				} else {
+					continue;
+				}
+			} else {
+				if ((str = strstr (*p, "/*")) != NULL) {
+					start = g_strndup (*p, str - *p);
 
-			if (**p == '#') {
-				continue;
+					if ((str = strstr (*p, "*/")) != NULL) {
+						str += 2;
+						end = g_strndup (str, strlen (*p) - strlen (str));
+					} else {
+						continue;
+					}
+				} 			
 			}
 
-			details = g_strsplit (*p, " ", 2);
+			/* Remove comments */
+			if (start && end) {
+				if (start[0] != '\0' && end[0] != '\0') {
+					line = g_strconcat (start, end, NULL);
+				}
+
+				g_free (start);
+				g_free (end);
+
+				start = NULL;
+				end = NULL;
+
+				if (!line) {
+					continue;
+				}
+			} else {
+				line = *p;
+			}
+
+			/* Check for comments and empty lines */
+			if (line[0] == '#' || line[0] == '\0') {
+				if (line != *p) {
+					g_free (line);
+				}
 
-			if (!details) {
 				continue;
 			}
 
-			if (!details[0] || !details[1]) {
+			/* Continue processing */
+			details = g_strsplit (line, " ", 2);
+
+			if (line != *p) {
+				g_free (line);
+			}
+
+			if (!details) {
+				continue;
+			} 
+			else if (!details[0] || !details[1]) {
 				g_strfreev (details);
 				continue;
 			}

Modified: trunk/src/tracker-indexer/tracker-indexer-db.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer-db.c	(original)
+++ trunk/src/tracker-indexer/tracker-indexer-db.c	Mon Oct 13 18:15:54 2008
@@ -399,6 +399,8 @@
 
 	metadata = tracker_metadata_new ();
 
+	g_return_val_if_fail (TRACKER_IS_SERVICE (service), metadata);
+
 	service_id_str = g_strdup_printf ("%d", service_id);
 	iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
 							     TRACKER_DB_CONTENT_TYPE_METADATA);
@@ -434,9 +436,8 @@
 	TrackerDBInterface *iface;
 	gchar *service_id_str;
 
-	if (service_id < 1) {
-		return;
-	}
+	g_return_if_fail (TRACKER_IS_SERVICE (service));
+	g_return_if_fail (service_id >= 1);
 
 	iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
 							     TRACKER_DB_CONTENT_TYPE_METADATA);
@@ -454,6 +455,37 @@
 }
 
 void
+tracker_db_delete_service_recursively (TrackerService *service,
+				       gchar          *service_path)
+{
+	TrackerDBInterface *iface;
+	gchar              *str;
+
+	g_return_if_fail (TRACKER_IS_SERVICE (service));
+	g_return_if_fail (service_path != NULL);
+
+	iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
+							     TRACKER_DB_CONTENT_TYPE_METADATA);
+
+	/* Delete from services table recursively */
+	str = g_strconcat (service_path, "/%", NULL);
+
+	/* We have to give two arguments. One is the actual path and
+	 * the second is a string representing the likeness to match
+	 * sub paths. Not sure how to do this in the .sql file
+	 * instead.
+	 */
+	tracker_db_interface_execute_procedure (iface,
+						NULL,
+						"DeleteServiceRecursively",
+						service_path,
+						str,
+						NULL);
+
+	g_free (str);
+}
+
+void
 tracker_db_move_service (TrackerService *service,
 			 const gchar	*from,
 			 const gchar	*to)
@@ -465,6 +497,10 @@
 	gchar *to_dirname;
 	gchar *to_basename;
 
+	g_return_if_fail (TRACKER_IS_SERVICE (service));
+	g_return_if_fail (from != NULL);
+	g_return_if_fail (to != NULL);
+
 	iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
 							     TRACKER_DB_CONTENT_TYPE_METADATA);
 

Modified: trunk/src/tracker-indexer/tracker-indexer-db.h
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer-db.h	(original)
+++ trunk/src/tracker-indexer/tracker-indexer-db.h	Mon Oct 13 18:15:54 2008
@@ -27,76 +27,72 @@
 #include "tracker-metadata.h"
 
 G_BEGIN_DECLS
-guint32		 tracker_db_get_new_service_id	  (TrackerDBInterface *iface);
-void		 tracker_db_increment_stats	  (TrackerDBInterface *iface,
-						   TrackerService     *service);
-void		 tracker_db_decrement_stats	  (TrackerDBInterface *iface,
-						   TrackerService     *service);
 
-/* Using path */
-gboolean	 tracker_db_check_service	  (TrackerService     *service,
-						   const gchar	      *dirname,
-						   const gchar	      *basename,
-						   guint32	      *id,
-						   time_t	      *mtime);
-guint		 tracker_db_get_service_type	  (const gchar	      *dirname,
-						   const gchar	      *basename);
+guint32          tracker_db_get_new_service_id         (TrackerDBInterface *iface);
+void             tracker_db_increment_stats            (TrackerDBInterface *iface,
+							TrackerService     *service);
+void             tracker_db_decrement_stats            (TrackerDBInterface *iface,
+							TrackerService     *service);
 
+/* Using path */
+gboolean         tracker_db_check_service              (TrackerService     *service,
+							const gchar        *dirname,
+							const gchar        *basename,
+							guint32            *id,
+							time_t             *mtime);
+guint            tracker_db_get_service_type           (const gchar        *dirname,
+							const gchar        *basename);
 
 /* Services  */
-gboolean	 tracker_db_create_service	  (TrackerService     *service,
-						   guint32	       id,
-						   const gchar	      *dirname,
-						   const gchar	      *basename,
-						   TrackerMetadata    *metadata);
-void		 tracker_db_delete_service	  (TrackerService     *service,
-						   guint32	       id);
-void		 tracker_db_move_service	  (TrackerService     *service,
-						   const gchar	      *from,
-						   const gchar	      *to);
-
+gboolean         tracker_db_create_service             (TrackerService     *service,
+							guint32             id,
+							const gchar        *dirname,
+							const gchar        *basename,
+							TrackerMetadata    *metadata);
+void             tracker_db_delete_service             (TrackerService     *service,
+							guint32             id);
+void             tracker_db_delete_service_recursively (TrackerService     *service,
+							gchar              *service_path);
+void             tracker_db_move_service               (TrackerService     *service,
+							const gchar        *from,
+							const gchar        *to);
 
 /* Metadata */
-void		 tracker_db_set_metadata	  (TrackerService     *service,
-						   guint32	       id,
-						   TrackerField       *field,
-						   const gchar	      *value,
-						   const gchar	      *parsed_value);
-TrackerMetadata *tracker_db_get_all_metadata	  (TrackerService     *service,
-						   guint32	       id,
-						   gboolean	       only_embedded);
-gchar	*	 tracker_db_get_parsed_metadata   (TrackerService     *service,
-						   guint32	       id);
-gchar	*	 tracker_db_get_unparsed_metadata (TrackerService     *service,
-						   guint32	       id);
-gchar  **	 tracker_db_get_property_values   (TrackerService     *service_def,
-						   guint32	       id,
-						   TrackerField       *field_def);
-void		 tracker_db_delete_all_metadata   (TrackerService     *service,
-						   guint32	       id);
-void		 tracker_db_delete_metadata	  (TrackerService     *service,
-						   guint32	       id,
-						   TrackerField       *field,
-						   const gchar	      *value);
+void             tracker_db_set_metadata               (TrackerService     *service,
+							guint32             id,
+							TrackerField       *field,
+							const gchar        *value,
+							const gchar        *parsed_value);
+TrackerMetadata *tracker_db_get_all_metadata           (TrackerService     *service,
+							guint32             id,
+							gboolean            only_embedded);
+gchar	*        tracker_db_get_parsed_metadata        (TrackerService     *service,
+							guint32             id);
+gchar	*        tracker_db_get_unparsed_metadata      (TrackerService     *service,
+							guint32             id);
+gchar  **        tracker_db_get_property_values        (TrackerService     *service_def,
+							guint32             id,
+							TrackerField       *field_def);
+void             tracker_db_delete_all_metadata        (TrackerService     *service,
+							guint32             id);
+void             tracker_db_delete_metadata            (TrackerService     *service,
+							guint32             id,
+							TrackerField       *field,
+							const gchar        *value);
 
 /* Contents */
-void		 tracker_db_set_text		  (TrackerService     *service,
-						   guint32	       id,
-						   const gchar	      *text);
-gchar	*	 tracker_db_get_text		  (TrackerService     *service,
-						   guint32	       id);
-void		 tracker_db_delete_text		  (TrackerService     *service,
-						   guint32	       id);
-
-
+void             tracker_db_set_text                   (TrackerService     *service,
+							guint32             id,
+							const gchar        *text);
+gchar	*        tracker_db_get_text                   (TrackerService     *service,
+							guint32             id);
+void             tracker_db_delete_text                (TrackerService     *service,
+							guint32             id);
 
 /* Events */
-void		 tracker_db_create_event	  (TrackerDBInterface *iface,
-						   guint32	       service_id,
-						   const gchar	      *type);
-
-
-
+void             tracker_db_create_event               (TrackerDBInterface *iface,
+							guint32             service_id,
+							const gchar        *type);
 
 G_END_DECLS
 

Modified: trunk/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer.c	(original)
+++ trunk/src/tracker-indexer/tracker-indexer.c	Mon Oct 13 18:15:54 2008
@@ -1408,6 +1408,7 @@
 {
 	TrackerService *service;
 	gchar *content, *metadata;
+	gchar *service_path;
 	const gchar *service_type;
 	guint service_id, service_type_id;
 
@@ -1482,10 +1483,18 @@
 	g_free (metadata);
 
 	/* Delete service */
+	service_path = g_build_path (G_DIR_SEPARATOR_S, 
+				     dirname, 
+				     basename, 
+				     NULL);
+
 	tracker_db_delete_service (service, service_id);
+	tracker_db_delete_service_recursively (service, service_path);
 	tracker_db_delete_all_metadata (service, service_id);
 
 	tracker_db_decrement_stats (indexer->private->common, service);
+
+	g_free (service_path);
 }
 
 static gboolean

Modified: trunk/src/trackerd/tracker-db.c
==============================================================================
--- trunk/src/trackerd/tracker-db.c	(original)
+++ trunk/src/trackerd/tracker-db.c	Mon Oct 13 18:15:54 2008
@@ -272,7 +272,6 @@
 	TrackerDBResultSet  *result_set, *result;
 	GArray		    *hits;
 	gint		     count;
-	gboolean	     detailed_emails = FALSE, detailed_apps = FALSE;
 	const gchar	    *procedure;
 	GArray		    *services = NULL;
 	GSList		    *duds = NULL;
@@ -335,10 +334,8 @@
 
 		if (detailed) {
 			if (strcmp (service, "Emails") == 0) {
-				detailed_emails = TRUE;
 				procedure = "GetEmailByID";
 			} else if (strcmp (service, "Applications") == 0) {
-				detailed_apps = TRUE;
 				procedure = "GetApplicationByID";
 			} else {
 				procedure = "GetFileByID2";
@@ -355,13 +352,10 @@
 
 		if (result_set) {
 			gchar *path;
+			guint  columns, i;
 
 			tracker_db_result_set_get (result_set, 0, &path, -1);
 
-			if (!detailed || detailed_emails || detailed_apps ||
-			    (detailed && g_file_test (path, G_FILE_TEST_EXISTS))) {
-				guint columns, i;
-
 				columns = tracker_db_result_set_get_n_columns (result_set);
 
 				if (G_UNLIKELY (!result)) {
@@ -380,7 +374,6 @@
 					_tracker_db_result_set_set_value (result, i, &value);
 					g_value_unset (&value);
 				}
-			}
 
 			g_free (path);
 			g_object_unref (result_set);

Modified: trunk/src/trackerd/tracker-processor.c
==============================================================================
--- trunk/src/trackerd/tracker-processor.c	(original)
+++ trunk/src/trackerd/tracker-processor.c	Mon Oct 13 18:15:54 2008
@@ -1417,14 +1417,16 @@
 {
 	TrackerProcessor *processor;
 	GFile		 *file;
+	const gchar      *module_name = "files";
 
 	processor = user_data;
 
 	g_message ("** CLEANING UP OLD MOUNT POINT:'%s'", mount_point);
 
-	/* Remove the monitor? */
+	/* Remove the monitor and item from the database */
 	file = g_file_new_for_path (mount_point);
-	tracker_monitor_remove (processor->private->monitor, "files", file);
+	tracker_monitor_remove (processor->private->monitor, module_name, file);
+	processor_files_delete (processor, module_name, file, TRUE);
 	g_object_unref (file);
 }
 



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