-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix WiFi transfer cancel, timeout, and post-transfer upload #4693
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
base: main
Are you sure you want to change the base?
Conversation
- Cancel now actively disconnects TCP transport and completes the transfer completer for immediate teardown instead of just setting a flag - Replace hard 5-minute timeout with 2-minute inactivity timer that resets on each data event, preventing premature timeout on slow transfers - Only clear SD card when transfer is fully complete (offset >= totalBytes), preventing data loss on partial transfers - Move UI state reset before BLE reconnection on cancel path for faster user feedback - Add background BLE reconnect helper for cancel path Co-Authored-By: Claude Opus 4.6 <[email protected]>
After WiFi transfer, the phone is connected to the device's WiFi AP which has no internet. Add a wait loop that polls for internet connectivity before attempting to upload files to the cloud, preventing immediate upload failures. Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request effectively addresses several key areas to improve WiFi transfer reliability and user experience. The immediate cancellation of WiFi transfers, the introduction of an inactivity timer instead of a fixed timeout, and the protection of SD card data during partial transfers are all significant improvements. Additionally, the new logic to wait for internet connectivity after a WiFi transfer before attempting cloud uploads enhances the robustness of the synchronization process.
| _activeTcpTransport = null; | ||
| _activeTransferCompleter = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These assignments are redundant as _resetSyncState() is called shortly after (line 1189), which already sets _activeTcpTransport and _activeTransferCompleter to null. Centralizing cleanup logic in _resetSyncState() improves maintainability.
References
- Prefer using existing helper functions over inlining their logic, especially when they handle complex cases like fallbacks or error handling. Inlining can introduce subtle bugs by missing parts of the original logic. In this case, redundant assignments are being made when an existing cleanup function already handles the state reset.
| _activeTcpTransport = null; | ||
| _activeTransferCompleter = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These assignments are redundant. The _cleanupWifiSync method, which is called in this catch block (line 1251), already invokes _resetSyncState() (line 751), which handles setting _activeTcpTransport and _activeTransferCompleter to null. Removing these duplicate assignments will make the code cleaner and prevent potential confusion.
References
- Prefer using existing helper functions over inlining their logic, especially when they handle complex cases like fallbacks or error handling. Inlining can introduce subtle bugs by missing parts of the original logic. In this case, redundant assignments are being made when an existing cleanup function already handles the state reset.
Summary
cancelSync()actively disconnects the TCP transport and completes the transfer completer instead of just setting a flag. UI state resets immediately; BLE reconnection happens in the background.offset >= storageTotalBytes). Previously, partial transfers could mark as complete and wipe the SD card.Test plan
🤖 Generated with Claude Code