Bug edited path bad mojave 859 (#864)

* Partial fix for #859, missing path edited on Mojave

* Fixed annotation issue

* Fix for HEIC edited images on Mojave, #859
This commit is contained in:
Rhet Turnbull
2022-12-11 19:30:28 -08:00
committed by GitHub
parent debc001af9
commit 53a61ed5aa
2 changed files with 18 additions and 5 deletions

View File

@@ -285,6 +285,16 @@ class PhotoInfo:
folder_id, file_id, nn_id = _get_resource_loc(edit_id)
# figure out what kind it is and build filename
library = self._db._library_path
if uti_edited := self.uti_edited:
ext = get_preferred_uti_extension(uti_edited)
if ext is not None:
filename = f"fullsizeoutput_{file_id}.{ext}"
return os.path.join(
library, "resources", "media", "version", folder_id, nn_id, filename
)
# if we get here, we couldn't figure out the extension
# so try to figure out the type and build the filename
type_ = self._info["type"]
if type_ == _PHOTO_TYPE:
# it's a photo

View File

@@ -1,7 +1,6 @@
__all__ = ["get_preferred_uti_extension", "get_uti_for_extension"]
""" get UTI for a given file extension and the preferred extension for a given UTI """
""" get UTI for a given file extension and the preferred extension for a given UTI
""" Implementation note: runs only on macOS
Implementation note: runs only on macOS
On macOS <= 11 (Big Sur), uses objective C CoreServices methods
UTTypeCopyPreferredTagWithClass and UTTypeCreatePreferredIdentifierForTag to retrieve the
@@ -17,6 +16,8 @@ __all__ = ["get_preferred_uti_extension", "get_uti_for_extension"]
It's a bit hacky but best I can think of to make this robust on different versions of macOS. PRs welcome.
"""
from __future__ import annotations
import csv
import re
import subprocess
@@ -27,6 +28,8 @@ import objc
from .utils import _get_os_version
__all__ = ["get_preferred_uti_extension", "get_uti_for_extension"]
# cached values of all the UTIs (< 6 chars long) known to my Mac running macOS 10.15.7
UTI_CSV = """extension,UTI,preferred_extension,MIME_type
c,public.c-source,c,None
@@ -565,7 +568,7 @@ def _get_ext_from_uti_dict(uti):
return None
def get_preferred_uti_extension(uti):
def get_preferred_uti_extension(uti: str) -> str | None:
"""get preferred extension for a UTI type
uti: UTI str, e.g. 'public.jpeg'
returns: preferred extension as str or None if cannot be determined"""
@@ -582,7 +585,7 @@ def get_preferred_uti_extension(uti):
# on MacOS 10.12, HEIC files are not supported and UTTypeCopyPreferredTagWithClass will return None for HEIC
if uti == "public.heic":
return "HEIC"
return "heic"
return None