bmc: simplify ::close()
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ibf6eb403e5262a625adfe50320f6c9cb7e601869
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index 06bc497..4504937 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -644,72 +644,56 @@
return false;
}
- /* Are you closing the verify blob? */
- if (item->second->activePath == verifyBlobId)
+ switch (state)
{
- switch (state)
- {
- case UpdateState::verificationPending:
- /* They haven't triggered, therefore closing is uninteresting.
- */
- break;
- case UpdateState::verificationStarted:
- /* TODO: If they close this blob before verification finishes,
- * that's an abort.
- */
- return false;
- case UpdateState::verificationCompleted:
- if (lastVerificationStatus == ActionStatus::success)
- {
- state = UpdateState::updatePending;
- addBlobId(updateBlobId);
- removeBlobId(verifyBlobId);
- }
- else
- {
- /* TODO: Verification failed, what now? */
- }
- break;
- default:
- break;
- }
- /* Must be verificationPending... not yet started, they may re-open and
- * trigger verification.
- */
- }
- else if (item->second->activePath == updateBlobId)
- {
- switch (state)
- {
- case UpdateState::updatePending:
- /* They haven't triggered the update, therefore this is
- * uninteresting. */
- break;
- case UpdateState::updateStarted:
- /* TODO: handle closing while update is running!. */
- break;
- case UpdateState::updateCompleted:
- if (lastUpdateStatus == ActionStatus::failed)
- {
- /* TODO: lOG something? */
- }
+ case UpdateState::uploadInProgress:
+ /* They are closing a data pathway (image, tarball, hash). */
+ state = UpdateState::verificationPending;
- state = UpdateState::notYetStarted;
- removeBlobId(updateBlobId);
- removeBlobId(activeImageBlobId);
- removeBlobId(activeHashBlobId);
- break;
- default:
- break;
- }
- }
- else
- {
- /* They are closing a data pathway (image, tarball, hash). */
- state = UpdateState::verificationPending;
+ /* Add verify blob ID now that we can expect it. */
+ addBlobId(verifyBlobId);
+ break;
+ case UpdateState::verificationPending:
+ /* They haven't triggered, therefore closing is uninteresting.
+ */
+ break;
+ case UpdateState::verificationStarted:
+ /* TODO: If they close this blob before verification finishes,
+ * that's an abort.
+ */
+ return false;
+ case UpdateState::verificationCompleted:
+ if (lastVerificationStatus == ActionStatus::success)
+ {
+ state = UpdateState::updatePending;
+ addBlobId(updateBlobId);
+ removeBlobId(verifyBlobId);
+ }
+ else
+ {
+ /* TODO: Verification failed, what now? */
+ }
+ break;
+ case UpdateState::updatePending:
+ /* They haven't triggered the update, therefore this is
+ * uninteresting. */
+ break;
+ case UpdateState::updateStarted:
+ /* TODO: handle closing while update is running!. */
+ break;
+ case UpdateState::updateCompleted:
+ if (lastUpdateStatus == ActionStatus::failed)
+ {
+ /* TODO: lOG something? */
+ }
- /* Add verify blob ID now that we can expect it. */
- addBlobId(verifyBlobId);
+ state = UpdateState::notYetStarted;
+ removeBlobId(updateBlobId);
+ removeBlobId(activeImageBlobId);
+ removeBlobId(activeHashBlobId);
+ break;
+ default:
+ break;
}
if (item->second->dataHandler)