Skip to content
Permalink
Browse files

account for duplicates on target add

  • Loading branch information...
jgor committed Jun 25, 2019
1 parent b04b932 commit c894a725da790bac2755dca71dd4041d31b93cf1
Showing with 2 additions and 10 deletions.
  1. +2 −10 dorkbot/dorkbot.py
@@ -275,23 +275,15 @@ def get_random_target(self):
def add_target(self, url):
try:
with self.db, closing(self.db.cursor()) as c:
c.execute("%s INTO targets VALUES (%s)" % (self.insert, self.param), (url,))
except self.module.IntegrityError as e:
if "UNIQUE constraint failed" in str(e):
return
pass
c.execute("%s INTO targets VALUES (%s) ON CONFLICT DO NOTHING" % (self.insert, self.param), (url,))
except self.module.Error as e:
print("ERROR adding target - %s" % e, file=sys.stderr)
sys.exit(1)

def add_targets(self, urls):
try:
with self.db, closing(self.db.cursor()) as c:
c.executemany("%s INTO targets VALUES (%s)" % (self.insert, self.param), [(url,) for url in urls])
except self.module.IntegrityError as e:
if "UNIQUE constraint failed" in str(e):
return
pass
c.executemany("%s INTO targets VALUES (%s) ON CONFLICT DO NOTHING" % (self.insert, self.param), [(url,) for url in urls])
except self.module.Error as e:
print("ERROR adding target - %s" % e, file=sys.stderr)
sys.exit(1)

0 comments on commit c894a72

Please sign in to comment.
You can’t perform that action at this time.