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: except KeyError:
upload_info = self.store.load_upload(self.name, content_uri) upload_info = self.store.load_upload(self.name, content_uri)
if not upload_info: if not upload_info:
return None, None, None return None, None
self.upload_info[content_uri] = upload_info 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) media_info = self.store.load_media(self.name, mxc_server, mxc_path)
if not media_info: if not media_info:
return None, None, None return None, None
self.media_info[(mxc_server, mxc_path)] = media_info self.media_info[(mxc_server, mxc_path)] = media_info
@ -1159,7 +1159,7 @@ class ProxyDaemon:
body=await response.transport_response.read(), 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 = urlparse(response.content_uri)
mxc_server = mxc.netloc.strip("/") mxc_server = mxc.netloc.strip("/")

View File

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

View File

@ -191,7 +191,7 @@ class TestClass(object):
upload = UploadInfo(event.url, filename, mimetype) 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) upload_cache = panstore.load_upload(server_name)