fix: stop after saving Media.thumbnail
This is what everything else targets, so choosing a different file, when it is available, only leads to confusion.
This commit is contained in:
@@ -246,13 +246,14 @@ def download_thumbnails(self) -> Path | None:
|
|||||||
if not paths:
|
if not paths:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
chosen_filename = PurePosixPath(self.thumbnail).name
|
||||||
width = getattr(settings, 'MEDIA_THUMBNAIL_WIDTH', 430)
|
width = getattr(settings, 'MEDIA_THUMBNAIL_WIDTH', 430)
|
||||||
height = getattr(settings, 'MEDIA_THUMBNAIL_HEIGHT', 240)
|
height = getattr(settings, 'MEDIA_THUMBNAIL_HEIGHT', 240)
|
||||||
saved_size = (0, 0)
|
saved_size = (0, 0)
|
||||||
thumb_path = None
|
thumb_path = None
|
||||||
try:
|
try:
|
||||||
for e_path in paths:
|
for e_path in paths:
|
||||||
if not ('.jpg' == e_path.suffix or 'maxresdefault' == e_path.stem):
|
if not (chosen_filename == e_path.name or '.jpg' == e_path.suffix or 'maxresdefault' == e_path.stem):
|
||||||
# accept: maxres webp, or any jpg thumbnails
|
# accept: maxres webp, or any jpg thumbnails
|
||||||
continue
|
continue
|
||||||
image_file = BytesIO()
|
image_file = BytesIO()
|
||||||
@@ -281,6 +282,8 @@ def download_thumbnails(self) -> Path | None:
|
|||||||
)
|
)
|
||||||
image_file = None
|
image_file = None
|
||||||
thumb_path = e_path
|
thumb_path = e_path
|
||||||
|
if chosen_filename == e_path.name:
|
||||||
|
break
|
||||||
except:
|
except:
|
||||||
temp_dir = (next(iter(paths))).parent
|
temp_dir = (next(iter(paths))).parent
|
||||||
rmtree(temp_dir, True)
|
rmtree(temp_dir, True)
|
||||||
|
|||||||
Reference in New Issue
Block a user