You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ae77791
Browse filesBrowse the repository at this point in the historyBrowse files
ADFA-4934: Fix findings from sixth high-effort code review of PR #1682
- ExternalFileInstallViewModel: confirmTemplateInstall() captured the
live currentRequestGeneration counter instead of the generation the
on-screen dialog actually belongs to. A second VIEW intent bumps that
counter synchronously before its own dialog is shown, so tapping
Install/Overwrite/Rename on the still-visible (but now stale) prior
dialog in that window got misattributed to the newer generation - on
success this incorrectly sent Finish, tearing the Activity down (and
its viewModelScope) out from under the newer, still in-flight request.
Fixed by tracking pendingConfirmationGeneration alongside
pendingConfirmationTempFile and keying confirmTemplateInstall() off
that; also guards against acting on a tempFile that's already been
superseded (and deleted) entirely.
- ExternalFileInstallViewModel: IgnoreTemplateInstall had the same root
cause - a stale Cancel tap unconditionally sent Finish regardless of
whether pendingConfirmationTempFile still matched. Now a no-op when
it doesn't.
- ExternalFileInstallViewModel: suggestUniqueBaseName()'s attempt-bound
check ran before the collision check, so the final candidate returned
when MAX_SUGGESTION_ATTEMPTS is hit was never actually checked for
collision. Reordered the && operands so the bound only short-circuits
after that last check has run.
- ExternalFileInstallViewModel: template install failures showed a
generic, non-actionable message; now includes the underlying reason
(reserved name / already exists / swap failure) via a %1$s arg,
matching PluginManagerViewModel's equivalent error path.
- PluginManagerViewModel: _uiEffect used the default rendezvous channel,
the same latent drop-before-collector-attaches bug class this PR
already fixed for ExternalFileInstallViewModel's channel. Switched to
Channel.BUFFERED for consistency; not user-visible today, but the
channel now also serves the forwarded-.cgp path.
- TemplateCollectionRepositoryImpl: extracted the renameTo()+copyTo()
fallback (triplicated across the backup/swap/restore steps) into a
single moveFile() helper.
Not fixed (narrow races / low-value at this stage, not regressions):
- installCollection() has no per-destination-name locking, so two
concurrent installs to the same target name could race on the final
swap. Requires two attachments sharing a name AND overlapping
generations to hit; accepted as last-write-wins for now.
- InstallTempFiles' hour-old sweep could delete a pending confirmation's
temp file if the user leaves a dialog open that long; would need
cross-ViewModel "file in use" tracking to fix properly.
- installPlugin() awaits initialLoadCompleted before copying the
incoming URI, when the two could run concurrently - a cold-start-only
latency nicety, not a correctness issue.
- dispatchTemplateInstall() does its zip-read/collision-check I/O before
its own generation check - inherent to check-then-act, the I/O can't
be skipped without knowing in advance it'll be superseded.
Verification: full app unit test suite green, including two new
regression tests for the generation-capture fix (confirming a stale
dialog surfaces success without Finish-ing over a newer request;
ignoring a stale dialog doesn't Finish over a newer one) and a
strengthened suggestUniqueBaseName test asserting the give-up candidate
was actually checked. On-device (R5CN80KZCKD): fresh install and
overwrite (via the new moveFile()) both verified with a real .cgt
archive - correct dialog content, clean success, no crash, no stray
.tmp/.bak files left in the templates directory.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
0 commit comments