Skip to content

Commit 5225ce6

Browse files
Merge branch 'main' into anoa/stop_using_logging_context_directly
2 parents 190686c + 1d93cbf commit 5225ce6

4 files changed

Lines changed: 31 additions & 9 deletions

File tree

.github/workflows/test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ jobs:
1515
with:
1616
python-version: "3.x"
1717
- name: Run synapse
18-
uses: michaelkaye/setup-matrix-synapse@v1.0.1
18+
uses: michaelkaye/setup-matrix-synapse@v1.0.5
1919
with:
20-
uploadLogs: true
20+
# This is turned off as it currently breaks runs. Can be re-enabled once
21+
# `setup-matrix-synapse` updates its `@actions/artifact` to
22+
# v2.x. See https://github.com/michaelkaye/setup-matrix-synapse/issues/102
23+
uploadLogs: false
2124
httpPort: 8008
2225
customModules: "synapse-s3-storage-provider"
2326
customConfig: |
@@ -58,7 +61,7 @@ jobs:
5861
server_name=`echo $mxc | sed 's^mxc://\(.*\)/.*^\1^'`
5962
media_id=`echo $mxc | sed 's^mxc://.*/\(.*\)^\1^'`
6063
#Downloading uploaded file
61-
curl -q -o round_trip http://127.0.0.1:8008/_matrix/media/v3/download/${server_name}/${media_id}/
64+
curl -q -o round_trip -H "Authorization: Bearer $access_token" http://127.0.0.1:8008/_matrix/client/v1/media/download/${server_name}/${media_id}
6265
#Verify file against original
6366
diff round_trip s3_storage_provider.py
6467
#Verify file against minio data store

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ media_storage_providers:
4848
# to S3. Each thread manages a single connection. Default is 40.
4949
#
5050
#threadpool_size: 20
51+
52+
# Set request_checksum_calculation or response_checksum_validation.
53+
# Depending on your S3 provider you may need to set these values,
54+
# especially if you are using a self-hosted system that does not
55+
# support the functionality provided by AWS.
56+
# Default is 'when_required'
57+
# request_checksum_calculation: "when_supported" | "when_required"
58+
# response_checksum_validation: "when_supported" | "when_required"
59+
5160
```
5261

5362
This module uses `boto3`, and so the credentials should be specified as

s3_storage_provider.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import boto3
2424
import botocore
25+
from botocore.config import Config
2526

2627
from twisted.internet import defer, reactor
2728
from twisted.python.failure import Failure
@@ -79,6 +80,11 @@ def __init__(self, hs, config):
7980
if "session_token" in config:
8081
self.api_kwargs["aws_session_token"] = config["session_token"]
8182

83+
self.api_kwargs["config"] = Config(
84+
response_checksum_validation=config.get("response_checksum_validation", "when_required"),
85+
request_checksum_calculation=config.get("request_checksum_calculation", "when_required")
86+
)
87+
8288
self._s3_client = None
8389
self._s3_client_lock = threading.Lock()
8490

@@ -153,13 +159,13 @@ def parse_config(config):
153159
}
154160

155161
if "region_name" in config:
156-
result["region_name"] = config["region_name"]
162+
result["region_name"] = str(config["region_name"])
157163

158164
if "endpoint_url" in config:
159165
result["endpoint_url"] = config["endpoint_url"]
160166

161167
if "access_key_id" in config:
162-
result["access_key_id"] = config["access_key_id"]
168+
result["access_key_id"] = str(config["access_key_id"])
163169

164170
if "secret_access_key" in config:
165171
result["secret_access_key"] = config["secret_access_key"]

scripts/s3_media_upload

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,15 +415,19 @@ def get_homeserver_db_conn(parser, homeserver_config_path):
415415
parser.error("%s is not valid yaml: %s" % (homeserver_config_path, e,))
416416

417417
try:
418-
database_name = homeserver_yaml["database"]["name"]
418+
database_engine_name = homeserver_yaml["database"]["name"]
419419
database_args = homeserver_yaml["database"]["args"]
420-
if database_name == "sqlite3":
421-
synapse_db_conn = sqlite3.connect(database=database_args["database"])
420+
if database_engine_name == "sqlite3":
421+
database_path = database_args["database"]
422+
synapse_db_conn = sqlite3.connect(database=database_path)
422423
else:
424+
# Determine the database name. "database" is a deprecated form of
425+
# the option name. See https://www.psycopg.org/docs/module.html
426+
database_name = database_args.get("dbname", database_args["database"])
423427
synapse_db_conn = psycopg2.connect(
424428
user=database_args["user"],
425429
password=database_args["password"],
426-
database=database_args["database"],
430+
database=database_name,
427431
host=database_args["host"],
428432
port=database_args["port"],
429433
)

0 commit comments

Comments
 (0)