Skip to content

Commit

Permalink
Be forgiving of situations in which a query result returns a nil path…
Browse files Browse the repository at this point in the history
…, perhaps as a result of a file going away during the query.
  • Loading branch information
jdberry committed Nov 4, 2013
1 parent 8b9e92e commit 6141eaf
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Tag/Tag.m
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,9 @@ - (NSPredicate*)formQueryPredicateForTags:(NSSet*)tagSet
{
NSAssert([tagSet count], @"Assumes there are tags to query for");

// Note for future: the following can be used to search for files that have
// no tags: [NSPredicate predicateWithFormat:@"NOT %K LIKE '*'", kMDItemUserTags]

NSPredicate* result;
if ([self wildcardInTagSet:tagSet])
{
Expand Down Expand Up @@ -672,11 +675,14 @@ - (void)queryComplete:sender;
{
@autoreleasepool {
NSMetadataItem* theResult = [_metadataQuery resultAtIndex:i];

NSURL* URL = [NSURL fileURLWithPath:[theResult valueForAttribute:(NSString *)kMDItemPath]];
NSArray* tagArray = [theResult valueForAttribute:kMDItemUserTags];

[self emitURL:URL tags:tagArray];
NSString* path = [theResult valueForAttribute:(NSString *)kMDItemPath];
if (path)
{
NSURL* URL = [NSURL fileURLWithPath:path];
NSArray* tagArray = [theResult valueForAttribute:kMDItemUserTags];

[self emitURL:URL tags:tagArray];
}
}
}

Expand Down

0 comments on commit 6141eaf

Please sign in to comment.