Skip to content

Commit cff725d

Browse files
Additions to Media de-duplication efforts (#210)
A little bit of clean up. Abstracting how the local path to the file is resolved. Ensure consistency when removing media, that if there are still references to the media that only the metadata is removed until it is the last reference. Resolving concerns about moving existing media by leaving it in place and only new media is de-duplicated. Stage incoming remote media into it's legacy file path until the sha256 can be discovered, and only after it is written to the database metadata is it moved into it's new place. This specific set of steps works with the file path resolving, so if the moving process is interrupted it will still be usable. Always provide `StorageProvider` classes with a consistent relative "path". For a media id of `1234567890`, it would break down to `12/34/567890`. Do not use the sha256 for this path. `StorageProvider`s are provided the `FileInfo` class as well, if they want to do media de-dupe they can get it from there. Should we provide an enhancement to the bundled `StorageProvider` to allow for this capability? Depends on #155
2 parents b8750f9 + 8fb8e19 commit cff725d

9 files changed

Lines changed: 605 additions & 299 deletions

File tree

.github/workflows/famedly-tests.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: Swatinem/rust-cache@68b3cb7503c78e67dae8373749990a220eb65352
2626
- uses: matrix-org/setup-python-poetry@v2
2727
with:
28-
python-version: "3.x"
28+
python-version: "3.13"
2929
poetry-version: "2.1.1"
3030
extras: "all"
3131
- run: poetry run scripts-dev/generate_sample_config.sh --check
@@ -49,7 +49,7 @@ jobs:
4949
- uses: actions/checkout@v4
5050
- uses: actions/setup-python@v5
5151
with:
52-
python-version: "3.x"
52+
python-version: "3.13"
5353
- run: .ci/scripts/check_lockfile.py
5454

5555
lint:
@@ -63,6 +63,7 @@ jobs:
6363
uses: matrix-org/setup-python-poetry@v2
6464
with:
6565
poetry-version: "2.1.1"
66+
python-version: "3.13"
6667
install-project: "false"
6768

6869
- name: Run ruff check
@@ -91,6 +92,7 @@ jobs:
9192
# https://github.com/matrix-org/synapse/pull/15376#issuecomment-1498983775
9293
# To make CI green, err towards caution and install the project.
9394
install-project: "true"
95+
python-version: "3.13"
9496
poetry-version: "2.1.1"
9597

9698
# Cribbed from
@@ -124,6 +126,7 @@ jobs:
124126
- uses: matrix-org/setup-python-poetry@v2
125127
with:
126128
poetry-version: "2.1.1"
129+
python-version: "3.13"
127130
extras: "all"
128131
- run: poetry run scripts-dev/check_pydantic_models.py
129132

@@ -161,7 +164,7 @@ jobs:
161164
- uses: actions/checkout@v4
162165
- uses: actions/setup-python@v5
163166
with:
164-
python-version: "3.x"
167+
python-version: "3.13"
165168
- run: "pip install rstcheck"
166169
- run: "rstcheck --report-level=WARNING README.rst"
167170

rust/src/http_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ fn get_runtime<'a>(reactor: &Bound<'a, PyAny>) -> PyResult<PyRef<'a, PyTokioRunt
137137
static DEFER: OnceCell<PyObject> = OnceCell::new();
138138

139139
/// Access to the `twisted.internet.defer` module.
140-
fn defer(py: Python<'_>) -> PyResult<&Bound<PyAny>> {
140+
fn defer(py: Python<'_>) -> PyResult<&Bound<'_, PyAny>> {
141141
Ok(DEFER
142142
.get_or_try_init(|| py.import("twisted.internet.defer").map(Into::into))?
143143
.bind(py))

0 commit comments

Comments
 (0)