fix: wait for macOS screenshot mtime to stabilize before reading#5
Merged
Merged
Conversation
Pre: getLatestMacScreenshot used a single 'skip if mtime is younger than 300ms' heuristic. macOS Cmd+Shift+3 on a large display can take longer than 300ms to fully write; the existing check could let a partially-written file through, causing sshshot to upload a corrupt PNG to the remote. Now: track the mtime we saw on the previous poll (lastObservedScreenshotMtime) and only proceed when the current mtime matches it. If the mtime changed, the OS is still flushing writes; wait another poll. The 300ms freshness check is kept as belt-and- suspenders for edge cases where stability is only one poll old. Trade-off: minimum delay between screenshot completion and upload goes from ~300ms to ~500ms (one poll cycle of stability + the 300ms check). Imperceptible to humans, eliminates the corruption risk.
|
🎉 This PR is included in version 0.4.5 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
flamerged
added a commit
that referenced
this pull request
May 1, 2026
…, clipboard reads (#14) Four items from the latest project review (P3/P4 cleanup): | # | Item | |---|------| | #2 | `getPidFile` deduped into config.ts (single source of truth) | | #3 | `taskkill` via spawnSync with array args | | #5 | `startBackground` Linux/macOS path: nohup execSync → spawn detached (closes the `\${remote}` shell-injection surface; the original 'native clipboard library crashes with detached' rationale is obsolete since @crosscopy/clipboard was removed) | | #6 | xclip / wl-paste / pngpaste / defaults clipboard reads via spawnSync | Net: zero remaining execSync calls with user-controlled string interpolation. All tests still pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review item #5. Replaces the 300ms freshness heuristic with an mtime-stability check — file must keep the same mtime for at least one full poll cycle before we read it. Prevents reading partially-written screenshots on slow disks.