Skip to content

Commit bd227e8

Browse files
committed
fix(macos): resolve finder -10010 error when laying out dmg
- Replace `container window of (POSIX file … as alias)` with explicit window target matching, as this throws AppleScript error -10010 on volume roots in modern macOS/CI environments - Match finder windows by comparing their POSIX paths (with and without trailing slash) to handle edge cases like pre-existing /Volumes/Stitch mounts - Remove `eject` call from finder automation and rely solely on closing matching windows, as eject on POSIX aliases triggers the same -10010 class error - Add delay after opening mount to allow finder window to settle before querying - Update dmg layout and detach logic to pass mount path with trailing slash variant for robust path comparison - Bump version to 0.1.156
1 parent 65f92e7 commit bd227e8

5 files changed

Lines changed: 44 additions & 17 deletions

File tree

.textile-monorepo-source

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
53ce11c2e79dccc8782edd597b4b5e5cb01ebfb5
1+
117a08291f972a928f36b7ada4c7f6daf9c66a29

.textile-stitch-release-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.155
1+
0.1.156

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stitch-bot"
3-
version = "0.1.155"
3+
version = "0.1.156"
44
edition = "2021"
55
description = "Stitch — Textile filler-network operator bot; market-makes the filler order book with signed UniswapX limit orders."
66
license = "AGPL-3.0-or-later"

packaging/macos/make-dmg.sh

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,38 @@ as_quote() {
7070
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
7171
}
7272
MNT_AS="$(as_quote "$MNT")"
73+
# Trailing slash form — Finder's POSIX path of a folder target usually includes it.
74+
MNT_AS_SLASH="$(as_quote "${MNT%/}/")"
7375
# Let the volume settle before scripting Finder.
7476
sleep 2
7577

7678
# Best-effort window layout: size, icon positions, and background. Finder
7779
# automation is available on the macOS CI runners; if it ever isn't, the image
7880
# still works — it just lacks the custom positions/arrow.
81+
#
82+
# Do NOT use `container window of (POSIX file … as alias)` — on modern macOS /
83+
# CI images that throws -10010 ("Handler can't handle objects of this class")
84+
# for volume roots. Open the mount, then pick the Finder window whose target
85+
# POSIX path matches this attach (so a pre-existing /Volumes/Stitch can't steal
86+
# the layout when we got /Volumes/Stitch 1).
7987
osascript <<OSA || echo "warning: Finder layout failed; shipping a plain drag-to-Applications image" >&2
80-
set mntAlias to POSIX file "$MNT_AS" as alias
88+
set mountPOSIX to "$MNT_AS"
89+
set mountPOSIXSlash to "$MNT_AS_SLASH"
8190
tell application "Finder"
91+
set mntAlias to (POSIX file mountPOSIX) as alias
8292
open mntAlias
83-
set win to container window of mntAlias
93+
delay 1
94+
set win to missing value
95+
repeat with w in (every Finder window)
96+
try
97+
set targetPath to POSIX path of (target of w as alias)
98+
if targetPath is mountPOSIX or targetPath is mountPOSIXSlash then
99+
set win to w
100+
exit repeat
101+
end if
102+
end try
103+
end repeat
104+
if win is missing value then error "no Finder window for " & mountPOSIX
84105
set current view of win to icon view
85106
set toolbar visible of win to false
86107
set statusbar visible of win to false
@@ -103,12 +124,12 @@ sync
103124

104125
# Finder often keeps the volume busy for a few seconds after layout (Spotlight /
105126
# .DS_Store / the container window). A single detach or even -force can fail with
106-
# "Resource busy" (hdiutil exit 16) on CI runners. Close/eject *this* mount via
107-
# its POSIX path, then retry detach with backoff before converting.
127+
# "Resource busy" (hdiutil exit 16) on CI runners. Close windows for *this* mount
128+
# via its POSIX path, then retry detach with backoff before converting.
108129
is_detached() {
109130
local target="$1"
110131
local mount="$2"
111-
# Mount point gone and device no longer listed → already ejected (e.g. via Finder).
132+
# Mount point gone and device no longer listed → already ejected.
112133
if [ ! -d "$mount" ] && ! hdiutil info 2>/dev/null | grep -Fq "$target"; then
113134
return 0
114135
fi
@@ -119,17 +140,23 @@ detach_dmg() {
119140
local target="$1"
120141
local mount="$2"
121142
local mount_as="$3"
143+
local mount_as_slash="$4"
122144
local attempt
123145
# Best-effort: drop Finder's hold on this mount before hdiutil fights it.
146+
# Avoid `eject` on a POSIX alias (same -10010 class error as container window);
147+
# closing matching windows is enough — hdiutil detach does the unmount.
124148
osascript <<OSA >/dev/null 2>&1 || true
125-
set mntAlias to POSIX file "$mount_as" as alias
149+
set mountPOSIX to "$mount_as"
150+
set mountPOSIXSlash to "$mount_as_slash"
126151
tell application "Finder"
127-
try
128-
close (every window whose target is mntAlias)
129-
end try
130-
try
131-
eject mntAlias
132-
end try
152+
repeat with w in (every Finder window)
153+
try
154+
set targetPath to POSIX path of (target of w as alias)
155+
if targetPath is mountPOSIX or targetPath is mountPOSIXSlash then
156+
close w
157+
end if
158+
end try
159+
end repeat
133160
end tell
134161
OSA
135162
if is_detached "$target" "$mount"; then
@@ -156,7 +183,7 @@ OSA
156183
return 1
157184
}
158185

159-
detach_dmg "$DEV" "$MNT" "$MNT_AS"
186+
detach_dmg "$DEV" "$MNT" "$MNT_AS" "$MNT_AS_SLASH"
160187
hdiutil convert "$TMP_DMG" -format UDZO -imagekey zlib-level=9 -o "$DMG" >/dev/null
161188

162189
# Ad-hoc ("-") DMGs aren't worth signing (nothing verifies them); sign only with

0 commit comments

Comments
 (0)