Fixed an issue where RcGcDw might crash due to previous image revision not having archivename

This commit is contained in:
Frisk 2025-01-02 01:32:19 +01:00
parent 774854c338
commit afc503a285

View file

@ -177,15 +177,19 @@ def embed_upload_upload(ctx: Context, change: dict) -> DiscordMessage:
if action in ("upload/overwrite", "upload/revert"):
if image_direct_url:
try:
revision = image_data["imageinfo"][num + 1]
archive_name = image_data["imageinfo"][num + 1]["archivename"]
except IndexError:
logger.exception(
"Could not analize the information about the image (does it have only one version when expected more in overwrite?) which resulted in no Options field: {}".format(
image_data["imageinfo"]))
except KeyError:
logger.exception(
"Could not analize the information about the image, one of its revisions might have been deleted: {}".format(
image_data["imageinfo"]))
else:
undolink = "{wiki}index.php?title={filename}&action=revert&oldimage={archiveid}".format(
wiki=ctx.client.WIKI_SCRIPT_PATH, filename=sanitize_to_url(change["title"]),
archiveid=revision["archivename"])
archiveid=archive_name)
embed.add_field(ctx._("Options"), ctx._("([preview]({link}) | [undo]({undolink}))").format(
link=image_direct_url, undolink=undolink))
if ctx.settings["appearance"]["embed"]["embed_images"]: