Compare commits
No commits in common. "adbb2d532b9d9a1bdc48a195f98219bc8b8feb36" and "930b48e55b1b010c423cfc018c1cead1e152c79c" have entirely different histories.
adbb2d532b
...
930b48e55b
2 changed files with 10 additions and 27 deletions
|
|
@ -98,8 +98,8 @@ async def main_with_ctx(ctx, wanted_date):
|
||||||
|
|
||||||
# write to output
|
# write to output
|
||||||
log.info("copying temp to output")
|
log.info("copying temp to output")
|
||||||
with output_path.open(mode="wb") as output_fdout:
|
with output_path.open(mode="wb") as output_fd:
|
||||||
shutil.copyfileobj(temp_fd, output_fdout)
|
shutil.copyfileobj(temp_fd, output_fd)
|
||||||
|
|
||||||
# decompress
|
# decompress
|
||||||
for url_type, _url in urls.items():
|
for url_type, _url in urls.items():
|
||||||
|
|
|
||||||
|
|
@ -150,33 +150,16 @@ async def posts_json():
|
||||||
if len(tags) != 1:
|
if len(tags) != 1:
|
||||||
return "unsupported query (only 1 tag)", 400
|
return "unsupported query (only 1 tag)", 400
|
||||||
|
|
||||||
first_tag = tags[0]
|
md5_tag = tags[0]
|
||||||
tag_parts = first_tag.split(":")
|
if not md5_tag.startswith("md5:"):
|
||||||
if len(tag_parts) != 2:
|
return "unsupported query (only md5 for now)", 400
|
||||||
return "unsupported query (tag must be a:b format)", 400
|
|
||||||
|
|
||||||
type, value = tag_parts
|
md5_prefix, md5_hexencoded_hash = md5_tag.split(":")
|
||||||
if type not in ("md5", "id"):
|
assert md5_prefix == "md5"
|
||||||
return (
|
|
||||||
"unsupported query (tag must be a:b format, and a must be id or md5)",
|
|
||||||
400,
|
|
||||||
)
|
|
||||||
|
|
||||||
if type == "md5":
|
|
||||||
md5_hexencoded_hash = value
|
|
||||||
rows = await app.db.execute_fetchall(
|
rows = await app.db.execute_fetchall(
|
||||||
"select * from posts where md5 = ?", (md5_hexencoded_hash,)
|
"select * from posts where md5 = ?", (md5_hexencoded_hash,)
|
||||||
)
|
)
|
||||||
elif type == "id":
|
|
||||||
try:
|
|
||||||
value = int(value)
|
|
||||||
except ValueError:
|
|
||||||
return "id:x x must be int", 400
|
|
||||||
rows = await app.db.execute_fetchall(
|
|
||||||
"select * from posts where id = ?", (value,)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
raise AssertionError("must be id or md5")
|
|
||||||
if not rows:
|
if not rows:
|
||||||
return {"posts": []}
|
return {"posts": []}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue