浏览代码

Fix bug when page contains unicode.

pull/24/head
Ben Kurtovic 12 年前
父节点
当前提交
859f388ee3
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. +2
    -2
      toolserver/copyvios/checker.py

+ 2
- 2
toolserver/copyvios/checker.py 查看文件

@@ -34,7 +34,7 @@ def get_results(bot, site, query):
def _get_cached_results(page, conn): def _get_cached_results(page, conn):
query1 = "DELETE FROM cache WHERE cache_time < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 DAY)" query1 = "DELETE FROM cache WHERE cache_time < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 DAY)"
query2 = "SELECT cache_url, cache_time, cache_queries, cache_process_time FROM cache WHERE cache_id = ? AND cache_hash = ?" query2 = "SELECT cache_url, cache_time, cache_queries, cache_process_time FROM cache WHERE cache_id = ? AND cache_hash = ?"
shahash = sha256(page.get()).hexdigest()
shahash = sha256(page.get().encode("utf8")).hexdigest()


with conn.cursor() as cursor: with conn.cursor() as cursor:
cursor.execute(query1) cursor.execute(query1)
@@ -62,7 +62,7 @@ def _format_date(cache_time):


def _cache_result(page, result, conn): def _cache_result(page, result, conn):
pageid = page.pageid pageid = page.pageid
shahash = sha256(page.get()).hexdigest()
shahash = sha256(page.get().encode("utf8")).hexdigest()
query1 = "SELECT 1 FROM cache WHERE cache_id = ?" query1 = "SELECT 1 FROM cache WHERE cache_id = ?"
query2 = "DELETE FROM cache WHERE cache_id = ?" query2 = "DELETE FROM cache WHERE cache_id = ?"
query3 = "INSERT INTO cache VALUES (?, ?, ?, CURRENT_TIMESTAMP, ?, ?)" query3 = "INSERT INTO cache VALUES (?, ?, ?, CURRENT_TIMESTAMP, ?, ?)"


正在加载...
取消
保存