You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2019/02/20 19:00:34 UTC

[mynewt-core] branch master updated: mgmt/imgmgr: Clear upload state on erase

This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 7d46bd5  mgmt/imgmgr: Clear upload state on erase
7d46bd5 is described below

commit 7d46bd5003674c04d689c26602b05a30f8201ad5
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Tue Feb 19 15:43:35 2019 -0800

    mgmt/imgmgr: Clear upload state on erase
    
    This fixes #1493.
    
    When an `image erase` command is successfully processed, reset the
    in-progress upload (if any).  Prior to this commit, a subsequent upload
    could resume an aborted upload, even if the partial image had since been
    erased.
---
 mgmt/imgmgr/src/imgmgr.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/mgmt/imgmgr/src/imgmgr.c b/mgmt/imgmgr/src/imgmgr.c
index 163517e..c5dedf7 100644
--- a/mgmt/imgmgr/src/imgmgr.c
+++ b/mgmt/imgmgr/src/imgmgr.c
@@ -99,8 +99,8 @@ static const struct mgmt_handler imgr_nmgr_handlers[] = {
 #endif
     },
     [IMGMGR_NMGR_ID_ERASE_STATE] = {
-            .mh_read = NULL,
-            .mh_write = imgr_erase_state,
+        .mh_read = NULL,
+        .mh_write = imgr_erase_state,
     },
 };
 
@@ -442,6 +442,10 @@ imgr_erase(struct mgmt_cbuf *cb)
     if (g_err) {
         return MGMT_ERR_ENOMEM;
     }
+
+    /* Reset in-progress upload. */
+    imgr_state.area_id = -1;
+
     return 0;
 }
 
@@ -486,6 +490,9 @@ imgr_erase_state(struct mgmt_cbuf *cb)
         return MGMT_ERR_ENOMEM;
     }
 
+    /* Reset in-progress upload. */
+    imgr_state.area_id = -1;
+
     return 0;
 }