@@ -137,7 +137,7 @@ int add_included_manifests(struct manifest *mom, struct list **subs)
137137 * hit the Manifest delta path. */
138138 ret = add_subscriptions (subbed , subs , mom , true, 0 );
139139 list_free_list (subbed );
140- if (ret & ( add_sub_ERR | add_sub_BADNAME ) ) {
140+ if (ret & add_sub_ERR ) {
141141 return ret ;
142142 }
143143
@@ -258,6 +258,47 @@ static struct list *create_update_list(struct manifest *server)
258258 return output ;
259259}
260260
261+ static void handle_deleted_bundles (struct manifest * current_manifest , struct manifest * server_manifest )
262+ {
263+ struct list * deletes = NULL ;
264+ struct list * list1 , * list2 ;
265+ struct file * file1 , * file2 ;
266+
267+ list1 = list_head (current_manifest -> files );
268+ list2 = list_head (server_manifest -> files );
269+
270+ while (list1 && list2 ) { /* m1/file1 matches m2/file2 */
271+ int ret ;
272+ file1 = list1 -> data ;
273+ file2 = list2 -> data ;
274+
275+ ret = str_cmp (file1 -> filename , file2 -> filename );
276+ if (ret == 0 ) {
277+ list1 = list1 -> next ;
278+ list2 = list2 -> next ;
279+ continue ;
280+ }
281+ if (ret < 0 ) { /* m1/file1 is before m2/file2 */
282+ file1 -> is_deleted = true;
283+ deletes = list_prepend_data (deletes , file1 );
284+ list1 = list1 -> next ;
285+ continue ;
286+ } /* else ret > 0 m1/file1 is after m2/file2 */
287+ list2 = list2 -> next ;
288+ }
289+
290+ while (list1 ) {
291+ file1 = list1 -> data ;
292+ file1 -> is_deleted = true;
293+ deletes = list_prepend_data (deletes , file1 );
294+ list1 = list1 -> next ;
295+ }
296+
297+ deletes = list_sort (deletes , cmp_file_filename_is_deleted );
298+ heuristics_apply (deletes );
299+ (void )rename_all_files_to_final (deletes );
300+ }
301+
261302enum swupd_code execute_update_extra (extra_proc_fn_t post_update_fn , extra_proc_fn_t file_validation_fn )
262303{
263304 int current_version = -1 , server_version = -1 ;
@@ -366,14 +407,8 @@ enum swupd_code execute_update_extra(extra_proc_fn_t post_update_fn, extra_proc_
366407 timelist_timer_start (globals .global_times , "Add included bundle manifests" );
367408 ret = add_included_manifests (server_manifest , & latest_subs );
368409 if (ret ) {
369- if (ret & add_sub_BADNAME ) {
370- /* this means a bundle(s) was removed in a future version */
371- warn ("One or more installed bundles are no longer available at version %d\n" ,
372- server_version );
373- } else {
374- ret = SWUPD_RECURSE_MANIFEST ;
375- goto clean_exit ;
376- }
410+ ret = SWUPD_RECURSE_MANIFEST ;
411+ goto clean_exit ;
377412 }
378413 timelist_timer_stop (globals .global_times ); // closing: Add included bundle manifests
379414
@@ -430,6 +465,11 @@ enum swupd_code execute_update_extra(extra_proc_fn_t post_update_fn, extra_proc_
430465 heuristics_apply (updates );
431466 timelist_timer_stop (globals .global_times ); // closing: Applying heuristics
432467 ret = update_loop (updates , server_manifest , file_validation_fn );
468+ if (!download_only ) {
469+ timelist_timer_start (globals .global_times , "Bundle deletes" );
470+ handle_deleted_bundles (current_manifest , server_manifest );
471+ timelist_timer_stop (globals .global_times ); // closing Bundle deletes
472+ }
433473 if (ret == 0 && !download_only ) {
434474 /* Failure to write the version file in the state directory
435475 * should not affect exit status. */
0 commit comments