Skip to content

Fix jpeg capture cancelling context - #86

Merged
davidnewhall merged 2 commits into
mainfrom
dn2_jpeg_fixes
Jul 20, 2026
Merged

Fix jpeg capture cancelling context#86
davidnewhall merged 2 commits into
mainfrom
dn2_jpeg_fixes

Conversation

@davidnewhall

Copy link
Copy Markdown
Collaborator

JPEG captures were not working well because of premature context cancellation. This resolves it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes unreliable JPEG still captures by ensuring the request context remains active until the response body is fully read, preventing truncated JPEG data and downstream decode failures.

Changes:

  • Refactors JPEG capture to first download raw bytes, then decode (avoids premature context cancellation).
  • Updates SaveJPEG to write server-provided JPEG bytes directly and adds JPEG-specific errors/constants.
  • Adjusts and expands tests to cover non-JPEG responses and slow/trickled response bodies.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
cameras.go Refactors GetJPEG/SaveJPEG to use a shared byte-fetch helper and changes fetch/timeout/error handling.
cameras_types.go Adds new JPEG-related error values and constants used by the new fetch/write logic.
cameras_internal_test.go Updates tests to validate new JPEG fetch behavior and new error conditions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cameras.go Outdated
Comment thread cameras.go Outdated
Comment thread cameras.go
Restore configurable Timeout/JPEGRetries, use O_EXCL for SaveJPEG,
and avoid reading full bodies on non-OK responses.

Co-authored-by: Cursor <cursoragent@cursor.com>
@davidnewhall
davidnewhall merged commit 773e6c2 into main Jul 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants