mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-03 17:24:13 -04:00
Run Black. (#5482)
This commit is contained in:
parent
7dcf984075
commit
32e7c9e7f2
376 changed files with 9142 additions and 10388 deletions
|
@ -44,6 +44,7 @@ class ContentRepoResource(resource.Resource):
|
|||
- Content type base64d (so we can return it when clients GET it)
|
||||
|
||||
"""
|
||||
|
||||
isLeaf = True
|
||||
|
||||
def __init__(self, hs, directory):
|
||||
|
@ -56,7 +57,7 @@ class ContentRepoResource(resource.Resource):
|
|||
# servers.
|
||||
|
||||
# TODO: A little crude here, we could do this better.
|
||||
filename = request.path.decode('ascii').split('/')[-1]
|
||||
filename = request.path.decode("ascii").split("/")[-1]
|
||||
# be paranoid
|
||||
filename = re.sub("[^0-9A-z.-_]", "", filename)
|
||||
|
||||
|
@ -69,17 +70,15 @@ class ContentRepoResource(resource.Resource):
|
|||
base64_contentype = filename.split(".")[1]
|
||||
content_type = base64.urlsafe_b64decode(base64_contentype)
|
||||
logger.info("Sending file %s", file_path)
|
||||
f = open(file_path, 'rb')
|
||||
request.setHeader('Content-Type', content_type)
|
||||
f = open(file_path, "rb")
|
||||
request.setHeader("Content-Type", content_type)
|
||||
|
||||
# cache for at least a day.
|
||||
# XXX: we might want to turn this off for data we don't want to
|
||||
# recommend caching as it's sensitive or private - or at least
|
||||
# select private. don't bother setting Expires as all our matrix
|
||||
# clients are smart enough to be happy with Cache-Control (right?)
|
||||
request.setHeader(
|
||||
b"Cache-Control", b"public,max-age=86400,s-maxage=86400"
|
||||
)
|
||||
request.setHeader(b"Cache-Control", b"public,max-age=86400,s-maxage=86400")
|
||||
|
||||
d = FileSender().beginFileTransfer(f, request)
|
||||
|
||||
|
@ -87,13 +86,15 @@ class ContentRepoResource(resource.Resource):
|
|||
def cbFinished(ignored):
|
||||
f.close()
|
||||
finish_request(request)
|
||||
|
||||
d.addCallback(cbFinished)
|
||||
else:
|
||||
respond_with_json_bytes(
|
||||
request,
|
||||
404,
|
||||
json.dumps(cs_error("Not found", code=Codes.NOT_FOUND)),
|
||||
send_cors=True)
|
||||
send_cors=True,
|
||||
)
|
||||
|
||||
return server.NOT_DONE_YET
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue