Skip to content

Commit

Permalink
Fix sync between registry and installer persistence (#72)
Browse files Browse the repository at this point in the history
Fixes ZMBTINST table in case of updates to tools bypassing installer
  • Loading branch information
mbtools authored Dec 11, 2023
1 parent 2b1760d commit f0032c5
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/core/#mbtools#cl_tool_manager.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,12 @@ CLASS /mbtools/cl_tool_manager IMPLEMENTATION.

DATA lv_file TYPE string.

lv_file = iv_title && '-x.y.z.zip'.
IF iv_title IS INITIAL.
lv_file = 'package-x.y.z.zip'.
ELSE.
lv_file = iv_title && '-x.y.z.zip'.
ENDIF.

REPLACE ALL OCCURRENCES OF ` ` IN lv_file WITH '-'.

SUBMIT /mbtools/mbt_installer
Expand Down Expand Up @@ -689,8 +694,9 @@ CLASS /mbtools/cl_tool_manager IMPLEMENTATION.
CONSTANTS lc_tabname TYPE tabname VALUE 'ZMBTINST'.

DATA:
ls_inst TYPE ty_inst,
ls_cont TYPE ty_content.
ls_inst TYPE ty_inst,
ls_inst_db TYPE ty_inst,
ls_cont TYPE ty_content.

ls_inst-name = io_tool->get_name( ).
ls_inst-pack = io_tool->get_package( ).
Expand All @@ -707,9 +713,14 @@ CLASS /mbtools/cl_tool_manager IMPLEMENTATION.
ls_inst-status = 'S'. "success
ls_cont = _sync_json( ls_inst ).

SELECT SINGLE * FROM (lc_tabname) INTO ls_cont WHERE name = ls_inst-name.
SELECT SINGLE * FROM (lc_tabname) INTO CORRESPONDING FIELDS OF ls_inst_db WHERE name = ls_inst-name.
IF sy-subrc = 0.
UPDATE (lc_tabname) FROM ls_cont.
IF ls_inst_db-pack <> ls_inst-pack.
DELETE FROM (lc_tabname) WHERE name = ls_inst-name ##SUBRC_OK.
INSERT (lc_tabname) FROM ls_cont ##SUBRC_OK.
ELSE.
UPDATE (lc_tabname) FROM ls_cont.
ENDIF.
IF sy-subrc <> 0.
/mbtools/cx_exception=>raise( 'Error updating MBT Installer persistence'(003) ).
ENDIF.
Expand All @@ -720,6 +731,8 @@ CLASS /mbtools/cl_tool_manager IMPLEMENTATION.
ENDIF.
ENDIF.

COMMIT WORK.

rv_result = abap_true.

ENDMETHOD.
Expand Down Expand Up @@ -868,7 +881,7 @@ CLASS /mbtools/cl_tool_manager IMPLEMENTATION.
DATA lo_json TYPE REF TO /mbtools/cl_ajson.

TRY.
lo_json = /mbtools/cl_ajson=>create_empty( ).
lo_json = /mbtools/cl_ajson=>create_empty( iv_keep_item_order = abap_true ).
lo_json->set( iv_path = '/'
iv_val = is_inst ).

Expand Down

0 comments on commit f0032c5

Please sign in to comment.