summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-12-02 19:51:47 +0000
committerMark Haines <mark.haines@matrix.org>2014-12-02 19:51:47 +0000
commit5da65085d106e98cf7b762836cb300d01226bf92 (patch)
treea6de5abe0e3485800f382221e861961578a82d2f /synapse/storage
parentWrite the upload portion of version 1 of the media repository (diff)
downloadsynapse-5da65085d106e98cf7b762836cb300d01226bf92.tar.xz
Get uploads working with new media repo
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/__init__.py6
-rw-r--r--synapse/storage/media_repository.py7
2 files changed, 11 insertions, 2 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py
index 1231794de0..f6811a8117 100644
--- a/synapse/storage/__init__.py
+++ b/synapse/storage/__init__.py
@@ -33,6 +33,7 @@ from .stream import StreamStore
 from .transactions import TransactionStore
 from .keys import KeyStore
 from .event_federation import EventFederationStore
+from .media_repository import MediaRepositoryStore
 
 from .state import StateStore
 from .signatures import SignatureStore
@@ -62,6 +63,7 @@ SCHEMAS = [
     "state",
     "event_edges",
     "event_signatures",
+    "media_repository",
 ]
 
 
@@ -81,7 +83,9 @@ class DataStore(RoomMemberStore, RoomStore,
                 RegistrationStore, StreamStore, ProfileStore, FeedbackStore,
                 PresenceStore, TransactionStore,
                 DirectoryStore, KeyStore, StateStore, SignatureStore,
-                EventFederationStore, ):
+                EventFederationStore,
+                MediaRepositoryStore,
+                ):
 
     def __init__(self, hs):
         super(DataStore, self).__init__(hs)
diff --git a/synapse/storage/media_repository.py b/synapse/storage/media_repository.py
index 73ceba3f2c..db03619a80 100644
--- a/synapse/storage/media_repository.py
+++ b/synapse/storage/media_repository.py
@@ -20,10 +20,15 @@ class MediaRepositoryStore(SQLBaseStore):
     """Persistence for attachments and avatars"""
 
     def get_local_media(self, media_id):
+        """Get the metadata for a local piece of media
+        Returns:
+            None if the media_id doesn't exist.
+        """
         return self._simple_select_one(
             "local_media_repository",
             {"media_id": media_id},
             ("media_type", "media_length", "upload_name", "created_ts"),
+            True,
         )
 
     def store_local_media(self, media_id, media_type, time_now_ms, upload_name,
@@ -36,7 +41,7 @@ class MediaRepositoryStore(SQLBaseStore):
                 "created_ts": time_now_ms,
                 "upload_name": upload_name,
                 "media_length": media_length,
-                "user_id": user_id,
+                "user_id": user_id.to_string(),
             }
         )