AF.3: open .afphoto by content without listing it for Finder

The macOS bundle must declare every File › Open extension, and the
packaging of a vector app must not mention raster-editor files. Affinity
Photo documents still open and place: the reader recognizes them by
their content, and a test checks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQPh8UDgMyARR5Hat9UchC
This commit is contained in:
callmeBalloch
2026-10-08 19:13:50 +00:00
committed by Claude
co-authored by Claude Opus 5.5
parent 2b4d8f4074
commit 2e55ce6d5b
4 changed files with 8 additions and 6 deletions
+3 -3
View File
@@ -556,7 +556,9 @@ pub const FORMATS: &[Format] = &[
Format { id: "wmf", label: "WMF", extensions: &["wmf"], mime: "image/wmf", read: true, write: true, raster: false, options: metafile::OPTIONS },
Format { id: "tga", label: "Targa", extensions: &["tga"], mime: "image/x-tga", read: false, write: true, raster: true, options: TGA_OPTIONS },
Format { id: "psd", label: "PSD", extensions: &["psd"], mime: "image/x-psd", read: false, write: true, raster: true, options: PSD_OPTIONS },
reader("affinity", "Affinity", &["af", "afdesign", "afphoto", "afpub"], "application/vnd.affinity", false),
// Affinity Photo's `.afphoto` opens by its content but isn't listed: Finder shouldn't offer a
// vector app for a raster editor's documents.
reader("affinity", "Affinity", &["af", "afdesign", "afpub"], "application/vnd.affinity", false),
];
/// Every extension `document.open` reads (the "All readable files" filter of open dialogs).
@@ -583,7 +585,6 @@ pub const OPEN_EXTS: &[&str] = &[
"eps",
"af",
"afdesign",
"afphoto",
"afpub",
];
@@ -626,7 +627,6 @@ pub const PLACE_EXTS: &[&str] = &[
"eps",
"af",
"afdesign",
"afphoto",
"afpub",
"txt",
];
@@ -57,7 +57,7 @@ fn preview_opens_with_a_warning_and_never_saves_to_the_source() {
}
let f = format("affinity").unwrap();
assert!(f.read && !f.write);
for ext in ["af", "afdesign", "afphoto", "afpub"] {
for ext in ["af", "afdesign", "afpub"] {
assert!(OPEN_EXTS.contains(&ext) && PLACE_EXTS.contains(&ext), "{ext}");
}
assert!(!SAVE_FORMATS.contains(&"affinity"));
@@ -271,6 +271,8 @@ mod native {
let mut s = Session::new();
let r = open_bytes(&mut s, "native.af", &document(method), Some("/source/native.af".into())).unwrap();
assert_eq!(r["format"], "affinity");
// Affinity Photo's extension isn't listed, but its documents still open by their content.
assert_eq!(open_bytes(&mut Session::new(), "native.afphoto", &document(method), None).unwrap()["format"], "affinity");
assert!(r["warnings"].as_array().unwrap().iter().all(|w| !w.as_str().unwrap().contains("preview")), "{r}");
let st = s.doc().unwrap();
assert!(st.path.is_none(), "Save must not write back over the Affinity file");