mirror of https://github.com/zulip/zulip.git
import script: Delete medium sized avatars if it exists.
Deletion of medium sized image is done if it exists before calling the function 'ensure_medium_avatar_image', to avoid potentially confusing problems with left-over medium-size avatar images from a previous run being used when repeatedly importing the same realm in a development environment.. Fixes #8949.
This commit is contained in:
parent
c63d1c9205
commit
ed7127c8b4
|
@ -1461,7 +1461,15 @@ def import_uploads_local(import_dir: Path, processing_avatars: bool=False,
|
||||||
for record in records:
|
for record in records:
|
||||||
if record['s3_path'].endswith('.original'):
|
if record['s3_path'].endswith('.original'):
|
||||||
user_profile = get_user_profile_by_id(record['user_profile_id'])
|
user_profile = get_user_profile_by_id(record['user_profile_id'])
|
||||||
# If medium sized avatar does not exist, this creates it using the original image
|
avatar_path = user_avatar_path_from_ids(user_profile.id, record['realm_id'])
|
||||||
|
medium_file_path = os.path.join(settings.LOCAL_UPLOADS_DIR, "avatars",
|
||||||
|
avatar_path) + '-medium.png'
|
||||||
|
if os.path.exists(medium_file_path):
|
||||||
|
# We remove the image here primarily to deal with
|
||||||
|
# issues when running the import script multiple
|
||||||
|
# times in development (where one might reuse the
|
||||||
|
# same realm ID from a previous iteration).
|
||||||
|
os.remove(medium_file_path)
|
||||||
upload_backend.ensure_medium_avatar_image(user_profile=user_profile)
|
upload_backend.ensure_medium_avatar_image(user_profile=user_profile)
|
||||||
|
|
||||||
def import_uploads_s3(bucket_name: str, import_dir: Path, processing_avatars: bool=False,
|
def import_uploads_s3(bucket_name: str, import_dir: Path, processing_avatars: bool=False,
|
||||||
|
|
Loading…
Reference in New Issue