1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 16:52:39 +00:00

skip bad rules instead of asserting - this might help down the road if rules are removed/changed

This commit is contained in:
Mitchell Livingston 2008-12-14 16:16:37 +00:00
parent 85995173f1
commit 1148805ec9

View file

@ -448,13 +448,10 @@ GroupsController * fGroupsInstance = nil;
if (![self usesAutoAssignRulesForIndex: index]) if (![self usesAutoAssignRulesForIndex: index])
return NO; return NO;
NSArray * rules = [self autoAssignRulesForIndex: index];
if (!rules || [rules count] == 0)
return NO;
const BOOL needAll = [self rulesNeedAllForIndex: index]; const BOOL needAll = [self rulesNeedAllForIndex: index];
BOOL anyPassed = NO;
NSEnumerator * iterator = [rules objectEnumerator]; NSEnumerator * iterator = [[self autoAssignRulesForIndex: index] objectEnumerator];
NSArray * rule = nil; NSArray * rule = nil;
while ((rule = [iterator nextObject])) while ((rule = [iterator nextObject]))
{ {
@ -465,9 +462,7 @@ GroupsController * fGroupsInstance = nil;
else if ([type isEqualToString: @"tracker"]) else if ([type isEqualToString: @"tracker"])
values = [torrent allTrackers: NO]; values = [torrent allTrackers: NO];
else else
NSAssert1(NO, @"\"%@\" - unknown criteria", type); continue;
BOOL match = NO;
NSStringCompareOptions options; NSStringCompareOptions options;
if ([place isEqualToString: @"begins"]) if ([place isEqualToString: @"begins"])
@ -477,14 +472,21 @@ GroupsController * fGroupsInstance = nil;
else if ([place isEqualToString: @"contains"]) else if ([place isEqualToString: @"contains"])
options = NSCaseInsensitiveSearch; options = NSCaseInsensitiveSearch;
else else
NSAssert2(NO, @"\"%@ - %@\" - unknown criteria", type, place); continue;
BOOL match = NO;
NSEnumerator * enumerator = [values objectEnumerator]; NSEnumerator * enumerator = [values objectEnumerator];
NSString * value; NSString * value;
while (!match && (value = [enumerator nextObject])) while ((value = [enumerator nextObject]))
{ {
NSRange result = [value rangeOfString: givenValue options: options]; NSRange result = [value rangeOfString: givenValue options: options];
match = result.location != NSNotFound; if (result.location != NSNotFound)
{
match = YES;
anyPassed = YES;
break;
}
} }
if (match && !needAll) if (match && !needAll)
@ -494,7 +496,7 @@ GroupsController * fGroupsInstance = nil;
else; else;
} }
return needAll; return anyPassed && needAll;
} }
@end @end