adium/adium

Parents ba261521004d
Children b552a65ccb58
Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
--- a/Other/Adium Spotlight Importer/GetMetadataForFile.m Mon Jun 25 02:10:25 2012 +0200
+++ b/Other/Adium Spotlight Importer/GetMetadataForFile.m Mon Jun 25 02:57:36 2012 +0200
@@ -307,11 +307,29 @@
NSString *CopyTextContentForXMLLogData(NSData *data) {
NSString *contentString = nil;
- NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithData:data options:NSXMLNodePreserveCDATA error:NULL];
+ NSError *err;
+ NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithData:data options:NSXMLNodePreserveCDATA error:&err];
+
if (xmlDoc) {
- NSArray *contentArray = [xmlDoc nodesForXPath:@"//message//text()" error:NULL];
- contentString = [contentArray componentsJoinedByString:@" "];
+ NSArray *children = [[xmlDoc rootElement] children];
+ NSMutableArray *messages = [NSMutableArray array];
+
+ for (NSXMLNode *child in children) {
+ if ([child.name isEqualToString:@"message"]) {
+ [messages addObject:child.stringValue];
+ }
+ }
+
+ if (messages.count) contentString = [messages componentsJoinedByString:@" "];
+
[xmlDoc release];
- }
+ } else {
+#ifdef AILogWithSignature
+ AILogWithSignature(@"Parsing log failed: %@", err);
+#endif
+ }
+
+ [contentString retain];
+
return contentString;
}
--- a/Source/AILoggerPlugin.m Mon Jun 25 02:10:25 2012 +0200
+++ b/Source/AILoggerPlugin.m Mon Jun 25 02:57:36 2012 +0200
@@ -1494,20 +1494,20 @@
* 3. On 10.3, this means that logs' markup is indexed in addition to their text, which is undesireable.
*/
- NSData *documentData = [CopyDataForURL(NULL, logURL) autorelease];
+ NSData *documentData = CopyDataForURL(NULL, logURL);
dispatch_semaphore_wait(jobSemaphore, DISPATCH_TIME_FOREVER);
dispatch_group_async(logIndexingGroup, defaultDispatchQueue, blockWithAutoreleasePool(^{
__block CFStringRef documentText = CopyTextContentForFileData(NULL, logURL, documentData);
- if (documentText) CFRetain(documentText);
+ [documentData release];
dispatch_group_async(logIndexingGroup, defaultDispatchQueue, blockWithAutoreleasePool(^{
CFRetain(searchIndex);
- if (documentText && bself.indexingAllowed) {
+ if (documentText && CFStringGetLength(documentText) > 0 && bself.indexingAllowed) {
static dispatch_queue_t skQueue = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{