EContact: Inline locally stored image does not retain its mime type
Description:
When trying to save an image and than loading that image the mime type did not retain its value.
Version:
- RHEL-9
- evolution-data-server-3.39.2-3.el9.x86_64
Reproducing script:
#!/usr/bin/env python3
import gi
from urllib.request import urlopen
gi.require_version("EBook", "1.2")
gi.require_version("EDataServer", "1.2")
gi.require_version("EBookContacts", "1.2")
from gi.repository import EBook
from gi.repository import EDataServer
from gi.repository import EBookContacts
registry = EDataServer.SourceRegistry.new_sync(None)
source = registry.ref_default_address_book()
address_book = EBook.BookClient.new(source)
image = "https://gitlab.gnome.org/GNOME/evolution/-/raw/master/data/icons/hicolor_actions_16x16_folder-copy.png"
photo = EBookContacts.ContactPhoto()
photo.type = EBookContacts.ContactPhotoType.INLINED
photo.set_mime_type("image/png")
photo_data = urlopen(image).read()
photo.set_inlined(photo_data)
contact = EBookContacts.Contact.new()
contact.set_property("photo", photo)
rc, id = address_book.add_contact_sync(contact, 0, None)
assert rc == True
rc, n_contact = address_book.get_contact_sync(id, None)
assert rc == True
rc, n_contact.inline_local_photos()
assert rc == True
n_photo = n_contact.get_property("photo")
assert n_photo.get_mime_type() == "image/png", "".join((
f"Expected value to be: 'image/png'\n",
f"Instead the value is: '{n_photo.get_mime_type()}'"
))
Expected result:
Mime type value will remain to be 'image/png'.
Actual result:
Mime type value was 'image/X-EVOLUTION-UNKNOWN'.
Edited by Milan Crha