@@ -143,12 +143,9 @@ async def fetch_media(self, file_info: FileInfo) -> Optional[Responder]:
143
143
"""
144
144
145
145
path = self ._file_info_to_path (file_info )
146
- local_path = os .path .join (self .local_media_directory , path )
147
- if os .path .exists (local_path ):
148
- return FileResponder (open (local_path , "rb" ))
149
146
150
- # Fallback for paths without method names
151
- # Should be removed in the future
147
+ # fallback for remote thumbnails with no method in the filename
148
+ legacy_path = None
152
149
if file_info .thumbnail and file_info .server_name :
153
150
legacy_path = self .filepaths .remote_media_thumbnail_rel_legacy (
154
151
server_name = file_info .server_name ,
@@ -157,15 +154,34 @@ async def fetch_media(self, file_info: FileInfo) -> Optional[Responder]:
157
154
height = file_info .thumbnail_height ,
158
155
content_type = file_info .thumbnail_type ,
159
156
)
157
+
158
+ local_path = os .path .join (self .local_media_directory , path )
159
+ if os .path .exists (local_path ):
160
+ logger .debug ("responding with local file %s" , local_path )
161
+ return FileResponder (open (local_path , "rb" ))
162
+
163
+ if legacy_path :
164
+ logger .debug (
165
+ "local file %s did not exist; checking legacy name" , local_path
166
+ )
160
167
legacy_local_path = os .path .join (self .local_media_directory , legacy_path )
161
168
if os .path .exists (legacy_local_path ):
169
+ logger .debug ("responding with local file %s" , legacy_local_path )
162
170
return FileResponder (open (legacy_local_path , "rb" ))
163
171
164
172
for provider in self .storage_providers :
165
173
res = await provider .fetch (path , file_info ) # type: Any
166
174
if res :
167
175
logger .debug ("Streaming %s from %s" , path , provider )
168
176
return res
177
+ if legacy_path :
178
+ logger .debug (
179
+ "Provider %s did not find %s; checking legacy name" , provider , path
180
+ )
181
+ res = await provider .fetch (legacy_path , file_info )
182
+ if res :
183
+ logger .debug ("Streaming %s from %s" , legacy_path , provider )
184
+ return res
169
185
170
186
return None
171
187
0 commit comments