mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-11-24 23:03:38 -05:00
Copy everything to backup
This commit is contained in:
parent
b77a13812c
commit
e283b555b1
5 changed files with 151 additions and 77 deletions
|
|
@ -59,6 +59,7 @@ class PreviewUrlResource(Resource):
|
|||
self.store = hs.get_datastore()
|
||||
self.client = SpiderHttpClient(hs)
|
||||
self.media_repo = media_repo
|
||||
self.primary_base_path = media_repo.primary_base_path
|
||||
|
||||
self.url_preview_url_blacklist = hs.config.url_preview_url_blacklist
|
||||
|
||||
|
|
@ -262,7 +263,8 @@ class PreviewUrlResource(Resource):
|
|||
|
||||
file_id = datetime.date.today().isoformat() + '_' + random_string(16)
|
||||
|
||||
fname = self.filepaths.url_cache_filepath(file_id)
|
||||
fpath = self.filepaths.url_cache_filepath_rel(file_id)
|
||||
fname = os.path.join(self.primary_base_path, fpath)
|
||||
self.media_repo._makedirs(fname)
|
||||
|
||||
try:
|
||||
|
|
@ -273,6 +275,9 @@ class PreviewUrlResource(Resource):
|
|||
)
|
||||
# FIXME: pass through 404s and other error messages nicely
|
||||
|
||||
with open(fname) as f:
|
||||
yield self.media_repo.copy_to_backup(f, fpath)
|
||||
|
||||
media_type = headers["Content-Type"][0]
|
||||
time_now_ms = self.clock.time_msec()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue