Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility for upcoming changes to Synapse #36

Merged
merged 3 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,6 @@ ENV/
# Temp files
*~
_trial*

# PyCharm project settings
.idea
10 changes: 8 additions & 2 deletions s3_storage_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@
from twisted.python.failure import Failure
from twisted.python.threadpool import ThreadPool

from synapse.logging.context import LoggingContext, make_deferred_yieldable
from synapse.rest.media.v1._base import Responder
from synapse.rest.media.v1.storage_provider import StorageProvider
from synapse.util.logcontext import LoggingContext, make_deferred_yieldable
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a deprecated import path last touched in July 2019 (1.2.0rc1).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I'm now realizing I didn't even end up touching this line at the end of this PR. I can revert if we want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing as this PR is about updating import paths I think it's fine to leave in :)


# Synapse 1.13.0 moved current_context to a module-level function.
try:
from synapse.logging.context import current_context
except ImportError:
current_context = LoggingContext.current_context

logger = logging.getLogger("synapse.s3")

Expand Down Expand Up @@ -93,7 +99,7 @@ def _store_file():

def fetch(self, path, file_info):
"""See StorageProvider.fetch"""
logcontext = LoggingContext.current_context()
logcontext = current_context()

d = defer.Deferred()
self._download_pool.callInThread(
Expand Down