1
0
mirror of https://github.com/r4sas/py-i2phosts synced 2025-09-03 17:42:11 +00:00

injector: use more efficient exists() method

This commit is contained in:
Hidden Z 2010-10-09 19:31:32 +00:00
parent bc33f75238
commit b71f2fc511

View File

@ -19,8 +19,9 @@ for line in f:
# check for already existed hosts in database to avoid adding duplicates # check for already existed hosts in database to avoid adding duplicates
# 1. do lookup by hostname # 1. do lookup by hostname
# 2. do lookup by base64 hash # 2. do lookup by base64 hash
if not i2phost.objects.filter(name=entry[0]) \ qs1 = i2phost.objects.filter(name=entry[0])
and not i2phost.objects.filter(b64hash=entry[1]): qs2 = i2phost.objects.filter(name=entry[1])
if not qs1.exists() and not qs2.exists():
print 'Adding %s' % entry[0] print 'Adding %s' % entry[0]
host = i2phost(name=entry[0], b64hash=entry[1], host = i2phost(name=entry[0], b64hash=entry[1],
description='Auto-added from external hosts.txt', description='Auto-added from external hosts.txt',