mirror of
https://github.com/taroved/pol
synced 2025-05-28 03:50:08 -07:00
md5
This commit is contained in:
parent
bc0545a3c8
commit
5f8a966422
@ -12,11 +12,11 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL("ALTER TABLE `frontend_post` ADD COLUMN `md5sum2` BINARY(128) DEFAULT 0 NOT NULL;"
|
||||
migrations.RunSQL("ALTER TABLE `frontend_post` ADD COLUMN `md5sum2` BINARY(16) DEFAULT 0 NOT NULL;"
|
||||
"UPDATE `frontend_post` set `md5sum2` = unhex(`md5sum`);"
|
||||
"ALTER TABLE frontend_post DROP COLUMN md5sum;"
|
||||
"ALTER TABLE frontend_post CHANGE COLUMN md5sum2 md5sum BINARY(128) NOT NULL;"
|
||||
"CREATE INDEX md5sum_index USING HASH ON frontend_post (feed_id, md5sum);",
|
||||
"ALTER TABLE frontend_post CHANGE COLUMN md5sum2 md5sum BINARY(16) NOT NULL;"
|
||||
"CREATE INDEX md5sum_index USING HASH ON frontend_post (feed_id, md5sum);", # hash works in MEMORY engine
|
||||
state_operations=[
|
||||
migrations.AlterField(
|
||||
model_name='post',
|
||||
|
@ -55,9 +55,9 @@ class Feed(object):
|
||||
fetched_dates = {}
|
||||
with closing(get_conn(self.db_creds)) as conn:
|
||||
with conn as cur:
|
||||
quoted_hashes = ','.join(["'%s'" % (i['md5']) for i in items])
|
||||
quoted_hashes = ','.join(["unhex('%s')" % (i['md5']) for i in items])
|
||||
|
||||
cur.execute("""select p.md5sum, p.created, p.id
|
||||
cur.execute("""select lower(hex(p.md5sum)), p.created, p.id
|
||||
from frontend_post p
|
||||
where p.md5sum in (%s)
|
||||
and p.feed_id=%s""" % (quoted_hashes, feed_id,))
|
||||
|
Loading…
x
Reference in New Issue
Block a user