@@ -191,7 +191,8 @@ static int32_t _generic_dt_control_fileop_images_job_run
191191 int32_t (* fileop_callback )(const int32_t ,
192192 const int32_t ),
193193 const char * desc ,
194- const char * desc_pl )
194+ const char * desc_pl ,
195+ const gboolean is_copy )
195196{
196197 dt_control_image_enumerator_t * params = dt_control_job_get_params (job );
197198 GList * t = params -> index ;
@@ -213,17 +214,32 @@ static int32_t _generic_dt_control_fileop_images_job_run
213214 return -1 ;
214215 }
215216
217+ int32_t col_count = dt_collection_get_collected_count ();
218+ char * old_chk = dt_collection_checksum (FALSE);
219+
216220 gboolean completeSuccess = TRUE;
217221 double prev_time = 0 ;
218222 while (t && !_job_cancelled (job ))
219223 {
220- completeSuccess &= (fileop_callback (GPOINTER_TO_INT (t -> data ), film_id ) != -1 );
224+ const gboolean success = fileop_callback (GPOINTER_TO_INT (t -> data ), film_id ) != -1 ;
225+ completeSuccess &= success ;
221226 t = g_list_next (t );
222227 fraction += 1.0 / total ;
223228 _update_progress (job , fraction , & prev_time );
229+ if (success ) col_count -- ;
224230 }
225231
226- if (completeSuccess )
232+ char * new_chk = dt_collection_checksum (FALSE);
233+ const gboolean col_changed = g_strcmp0 (old_chk , new_chk ) != 0 ;
234+ g_free (old_chk );
235+ g_free (new_chk );
236+
237+ // If there is no more image in the current collection or we did a
238+ // copy and we did not change to a new collection then jump to the
239+ // new location.
240+ if (completeSuccess
241+ && !col_changed
242+ && (col_count == 0 || is_copy ))
227243 {
228244 char collect [1024 ];
229245 snprintf (collect , sizeof (collect ), "1:0:0:%s$" , new_film .dirname );
@@ -1456,14 +1472,16 @@ static int32_t _control_move_images_job_run(dt_job_t *job)
14561472{
14571473 return _generic_dt_control_fileop_images_job_run (job , & dt_image_move ,
14581474 _ ("moving %d image" ),
1459- _ ("moving %d images" ));
1475+ _ ("moving %d images" ),
1476+ FALSE);
14601477}
14611478
14621479static int32_t _control_copy_images_job_run (dt_job_t * job )
14631480{
14641481 return _generic_dt_control_fileop_images_job_run (job , & dt_image_copy ,
14651482 _ ("copying %d image" ),
1466- _ ("copying %d images" ));
1483+ _ ("copying %d images" ),
1484+ TRUE);
14671485}
14681486
14691487static int32_t _control_local_copy_images_job_run (dt_job_t * job )
0 commit comments