Repository navigation
K2GO-372 fix(restore): ask before reading, and show one bar for the whole run - #523
Merged
Merged
Conversation
…ve early A restore streams the archive twice -- the safety listing pass the traversal guard needs, then extraction -- and reported both as an indeterminate spinner. On a 4.86 GB backup that is about five minutes with nothing to distinguish it from a hang. The two-phase byte bar already existed for the rootfs install (ADFA-5118); the restore simply never consumed it, setting -1 and implementing only the no-op onProgress. It now maps both passes onto one 0-100 bar. The identity check also ran after the listing, so a wrong-ABI backup was refused only once a full decompression had been paid for. The manifest that answers it is packed first by the backup writer, so reading it up front refuses the same files in about a second. The rule itself moves to deploy/domain/RootfsIdentity, pure and with the app ABI passed in, because as written it could not be unit-tested -- it read the ABI from android.os and its input had a private constructor. RootfsArchiveValidator keeps one thin adapter, so the early check and the full validation cannot drift apart. No new strings, no archive-format change, and the listing pass is untouched.
…hole run The destructive confirm waited on a full copy plus a full validation listing of the archive — over three minutes for a 2.4 GB backup — so the user had to stay and watch a motionless screen to answer a question the file's contents do not affect. The confirm comes first now, and every slow read belongs to DeepOpService, measured and behind the foreground notification. The pre-flight validation was a second place answering what TarExtractor already answers: it checks identity, lists the archive and fails closed before writing anything. Deleting it removes one full read of the archive and one of the two "Checking the file" labels; validate(), resolveTar() and listEntries() go with it. The copy becomes one of the run's three passes and shares the single bar (ExtractProgress maps N passes now, not two) instead of filling it and sending it back to zero. The damage marker is planted at the first byte written rather than at service start: the copy and the verify pass damage nothing, and an archive the extractor rejects must not leave the system marked damaged. The rejection's reason reaches the screen instead of a generic failure. The status line uses the fixed-width ellipsis so it stops sliding as its dots grow, and the "this can take a while" card is hidden once the op has finished, where it was asking the user to wait for something that already happened.
…is the archive's first member, so a few KB of the SAF stream refuse a wrong-ABI or non-rootfs backup in about three seconds instead of after a multi-gigabyte copy (measured 52s -> 3s on a 1.26 GB archive). Gzip is detected from the magic bytes, since a SAF uri has no filename to read an extension from. The Result-to-reason mapping, which TarExtractor spelled out twice inline, moves to RootfsArchiveValidator.rejectionMessage for its three callers.
…eck for what it is Second-pass review of the K2GO-372 change. Two one-line hardenings, and three notes so the next reader does not undo something that was deliberate. - The staged archive is deleted when the staging thread returns to a service that already reached a terminal. Unreachable while a restore is uncancellable, but the file is gigabytes and the branch left it in the cache. - The staging copy ends only on -1; a zero-length read used to end it and silently truncate the copy. - rejectBeforeCopy() stops sharing a name with RootfsArchiveValidator.identityRejection(): one returns a message to show, the other a verdict. - rejectionMessage() records that it also rejects CORRUPT, which the extractor's two inline chains did not — failing closed is the right direction and it is inert on today's callers — and that UNREADABLE deliberately does not reject there, a gap that predates it. - TarExtractor says why its identity check is not a duplicate of the pre-copy one: it is the fail-closed gate every caller shares, and it judges the artifact actually about to be extracted.
…e the extract The guard was only ever asked whether the expanded tree would fit, and only once the picked archive had already been copied into the cache — so the copy itself, gigabytes of it, was never covered. A device with room for neither filled up mid-copy and reported it as an unreadable file. SpaceEstimate.peakForRestore() names what a restore needs free at once: the staged copy plus the tree it expands into, both on disk together until the extraction finishes. The service asks it before copying, using the length the provider reports. This is the same requirement asked earlier, not a stricter one: the old check wanted free-after-copy >= expansion, this one wants free-before-copy >= copy + expansion, and the two differ by exactly the copy. The check in runRestore stays as the authoritative gate, for when the provider reports no length or the disk moves in between, and both now spell "it does not fit" the same way.
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.
Restoring a backup asked the destructive question last and showed no progress at all.
Picking a file copied it into the cache and fully listed it — two complete reads of a
multi-gigabyte archive — and only then asked "replace your system?". Answering it meant
staying in front of a motionless screen for over three minutes on a 2.4 GB backup. The
ten minutes that followed reported nothing: an indeterminate spinner, indistinguishable
from a hang.
What changed
now belongs to
DeepOpService, so it is measured, it survives backgrounding, and theuser can walk away as soon as they have answered.
ExtractProgressmaps N passes onto one bar instead of two, so copy / check / restoreshare a single 0-100 rather than each filling it and sending it back to zero.
TarExtractoralready answers: identity, then the full listing, failing closed beforewriting anything.
validate(),resolveTar()andlistEntries()go with it.archive's first member, so a few KB of the SAF stream refuse a wrong-ABI or non-rootfs
backup immediately. Gzip is detected from the magic bytes, since a SAF uri carries no
filename to read an extension from.
copy and the verify pass damage nothing, so an ungraceful exit during them no longer
declares a false DAMAGED, and an archive the extractor rejects no longer leaves the
system marked damaged.
sliding as its dots grow, and the "this can take a while" card is hidden once the
operation has finished.
Reduction
No new flags and no new mutable state. The guard is planted lazily by reading the marker
itself (
InstallGuard.isLive) rather than mirroring it in a boolean.Verified on device
66% -> restore 78%, 87%. It never returns to zero.
on screen; marker absent, rootfs untouched, environment lock released.
translated.
Out of scope
Three pre-existing issues found while reviewing, each with its own ticket: the extractor
proceeds on an
UNREADABLEvalidation verdict, and dismissing the confirm by tappingoutside dead-ends the screen.