Browse Source

injector: use more efficient exists() method

pull/1/head
Hidden Z 14 years ago
parent
commit
b71f2fc511
  1. 5
      injector

5
injector

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

Loading…
Cancel
Save