store filename in upload info

This commit is contained in:
Andrea Spacca 2021-01-07 17:08:34 +01:00
parent b6b4362ade
commit 6cedf846bd
3 changed files with 6 additions and 5 deletions

View File

@ -837,7 +837,7 @@ class ProxyDaemon:
except KeyError:
upload_info = self.store.load_upload(self.name, content_uri)
if not upload_info:
return None, None, None
return None, None
self.upload_info[content_uri] = upload_info
@ -848,7 +848,7 @@ class ProxyDaemon:
media_info = self.store.load_media(self.name, mxc_server, mxc_path)
if not media_info:
return None, None, None
return None, None
self.media_info[(mxc_server, mxc_path)] = media_info
@ -1159,7 +1159,7 @@ class ProxyDaemon:
body=await response.transport_response.read(),
)
self.store.save_upload(self.name, response.content_uri, content_type)
self.store.save_upload(self.name, response.content_uri, file_name, content_type)
mxc = urlparse(response.content_uri)
mxc_server = mxc.netloc.strip("/")

View File

@ -201,12 +201,13 @@ class PanStore:
return None
@use_database
def save_upload(self, server, content_uri, mimetype):
def save_upload(self, server, content_uri, filename, mimetype):
server = Servers.get(name=server)
PanUploadInfo.insert(
server=server,
content_uri=content_uri,
filename=filename,
mimetype=mimetype,
).on_conflict_ignore().execute()

View File

@ -191,7 +191,7 @@ class TestClass(object):
upload = UploadInfo(event.url, filename, mimetype)
panstore.save_upload(server_name, event.url, mimetype)
panstore.save_upload(server_name, event.url, filename, mimetype)
upload_cache = panstore.load_upload(server_name)