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

Already on GitHub? Sign in to your account

Feature: Implement purge_media_cache admin API #902

Merged
merged 3 commits into from Jun 29, 2016

Conversation

Projects
None yet
2 participants
Owner

erikjohnston commented Jun 29, 2016 edited

Adds an API to purge old remote media that has been locally cached. API:

POST /_matrix/client/api/v1/admin/purge_media_cache?access_token=X&before_ts=1467208470882

200 OK
{
    "deleted": 5
}

This purges all cached remote media that was last accessed before the time given by before_ts.

The requester must be a server admin.

erikjohnston added some commits Jun 29, 2016

@erikjohnston erikjohnston changed the title from Implement purge_media_cache admin API to Feature: Implement purge_media_cache admin API Jun 29, 2016

@NegativeMjark NegativeMjark commented on an outdated diff Jun 29, 2016

synapse/rest/media/v1/media_repository.py
+ else:
+ continue
+
+ try:
+ os.removedirs(full_dir)
+ except OSError:
+ pass
+
+ thumbnail_dir = self.filepaths.remote_media_thumbnail_dir(
+ origin, file_id
+ )
+ shutil.rmtree(thumbnail_dir, ignore_errors=True)
+
+ yield self.store.delete_remote_media(origin, media_id)
+ try:
+ os.removedirs(thumbnail_dir)
@NegativeMjark

NegativeMjark Jun 29, 2016

Contributor

Hmm, will this race with adding an item under a different key?

Contributor

NegativeMjark commented Jun 29, 2016

LGTM

@erikjohnston erikjohnston merged commit aac546c into develop Jun 29, 2016

9 of 10 checks passed

Sytest Dendron (Commit) Build #198 origin/erikj/expire_media failed in 23 min
Details
Flake8 + Packaging (Commit) Build #1082 origin/erikj/expire_media succeeded in 35 sec
Details
Flake8 + Packaging (Merged PR) Build finished.
Details
Sytest Dendron (Merged PR) Build finished.
Details
Sytest Postgres (Commit) Build #1038 origin/erikj/expire_media succeeded in 5 min 47 sec
Details
Sytest Postgres (Merged PR) Build finished.
Details
Sytest SQLite (Commit) Build #1054 origin/erikj/expire_media succeeded in 5 min 35 sec
Details
Sytest SQLite (Merged PR) Build finished.
Details
Unit Tests (Commit) Build #1121 origin/erikj/expire_media succeeded in 1 min 26 sec
Details
Unit Tests (Merged PR) Build finished.
Details

@richvdh richvdh deleted the erikj/expire_media branch Dec 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment