@@ -962,10 +962,11 @@ def __init__(self, *args, **kwargs):
962
962
if NewerModeMixin .MODE_NAME in kwargs :
963
963
self .self_kwargs [NewerModeMixin .MODE_NAME ] = True
964
964
965
- # retain a history of how this command was called
966
- self .task_kwargs = json .dumps (self .self_kwargs , sort_keys = True )
967
-
968
965
super (UpdateIndexAction , self ).__init__ (* args , ** kwargs )
966
+ if self .task_kwargs == '{}' and self .self_kwargs :
967
+ # retain a history of how this command was called
968
+ self .task_kwargs = json .dumps (self .self_kwargs , sort_keys = True )
969
+
969
970
self ._batch_num = 0
970
971
self ._expected_remaining = 0
971
972
self ._indexed_docs = 0
@@ -1103,6 +1104,14 @@ def perform_action(self, dem_index, *args, **kwargs):
1103
1104
use_self_dict_format = True
1104
1105
)
1105
1106
1107
+ def apply_to_newer (self , given_version , action = None ):
1108
+ versions = self .index .get_newer_versions (given_version = given_version )
1109
+ kwargs = deepcopy (self .self_kwargs )
1110
+ # we don't want child update index actions to also do 'newer' tasks
1111
+ kwargs .pop (NewerModeMixin .MODE_NAME )
1112
+ update_index_action = UpdateIndexAction (** kwargs )
1113
+ super (UpdateIndexAction , self ).apply_to_newer (versions , update_index_action )
1114
+
1106
1115
def prepare_action (self , dem_index ):
1107
1116
self ._index_name = self .index .name
1108
1117
self ._index_version_id = dem_index .get_version_id ()
@@ -1119,12 +1128,8 @@ def prepare_action(self, dem_index):
1119
1128
raise IllegalDEMIndexState (msg )
1120
1129
1121
1130
if self .newer_mode :
1122
- versions = self .index .get_newer_versions (given_version = index_version )
1123
- kwargs = deepcopy (self .self_kwargs )
1124
- # we don't want child update index actions to also do 'newer' tasks
1125
- kwargs .pop (NewerModeMixin .MODE_NAME )
1126
- update_index_action = UpdateIndexAction (** kwargs )
1127
- self .apply_to_newer (versions , update_index_action )
1131
+ self .apply_to_newer (index_version )
1132
+ return
1128
1133
else :
1129
1134
self .index_version = index_version
1130
1135
self ._index_version_name = index_version .name
@@ -1157,9 +1162,7 @@ def prepare_action(self, dem_index):
1157
1162
raise NoActiveIndexVersion (msg )
1158
1163
1159
1164
if self .newer_mode :
1160
- versions = self .index .get_newer_versions (given_version = active_version )
1161
- self .apply_to_newer (versions , UpdateIndexAction ())
1162
- # we're done, because the newer versions will get their own actions
1165
+ self .apply_to_newer (active_version )
1163
1166
return
1164
1167
1165
1168
# we have an active version for this index. now do the update.
0 commit comments