Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macCreatorType] preserve existing other metadata when setting filetype & creator #3171

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion Lib/fontTools/misc/macCreatorType.py
Expand Up @@ -52,5 +52,11 @@

if not all(len(s) == 4 for s in (fileCreator, fileType)):
raise TypeError("arg must be string of 4 chars")
finderInfo = pad(bytesjoin([fileType, fileCreator]), 32)
try:
existingFinderInfo = xattr.getxattr(path, "com.apple.FinderInfo")
except (KeyError, IOError):
pass

Check warning on line 58 in Lib/fontTools/misc/macCreatorType.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/misc/macCreatorType.py#L55-L58

Added lines #L55 - L58 were not covered by tests
else:
otherMetadata = existingFinderInfo[8:]
finderInfo = pad(bytesjoin([fileType, fileCreator, otherMetadata]), 32)

Check warning on line 61 in Lib/fontTools/misc/macCreatorType.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/misc/macCreatorType.py#L60-L61

Added lines #L60 - L61 were not covered by tests
xattr.setxattr(path, "com.apple.FinderInfo", finderInfo)