Skip to content

Commit

Permalink
Return right returnvalue on import/export/move cmd.
Browse files Browse the repository at this point in the history
We were always returning 0 (e.g. operation failed) for
the import/export/move commands. This makes any runscript fail
any next runscript and the Job also fails.

Fixes #146: Variable "Job Exit Code" in mailcommand reports always
            "Error" when doing copy or migration job
Fixes #155: runafterjob doesn't get executed if a runscript directive is
            placed before the directive runafterjob
  • Loading branch information
Marco van Wieringen committed May 5, 2013
1 parent e407353 commit 9d5f626
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/dird/ua_impexp.c
Expand Up @@ -1003,7 +1003,7 @@ static char *move_volumes_in_autochanger(UAContext *ua,
* - export of normal slots into export slots
* - move from one normal slot to an other normal slot
*/
static void perform_move_operation(UAContext *ua, enum e_move_op operation)
static int perform_move_operation(UAContext *ua, enum e_move_op operation)
{
bool scan;
USTORERES store;
Expand All @@ -1016,18 +1016,19 @@ static void perform_move_operation(UAContext *ua, enum e_move_op operation)
nr_enabled_dst_slots = 0;
int drive = -1;
int i, max_slots;
int retval = 0;

store.store = get_storage_resource(ua, false/*no default*/);
if (!store.store) {
return;
return retval;
}

switch (store.store->Protocol) {
case APT_NDMPV2:
case APT_NDMPV3:
case APT_NDMPV4:
ua->warning_msg(_("Storage has non-native protocol.\n"));
return;
return retval;
default:
break;
}
Expand All @@ -1052,7 +1053,7 @@ static void perform_move_operation(UAContext *ua, enum e_move_op operation)
max_slots = get_num_slots_from_SD(ua);
if (max_slots <= 0) {
ua->warning_msg(_("No slots in changer.\n"));
return;
return retval;
}

/*
Expand Down Expand Up @@ -1321,6 +1322,8 @@ static void perform_move_operation(UAContext *ua, enum e_move_op operation)
update_slots_from_vol_list(ua, store.store, vol_list, visited_slot_list);
}

retval = 1;

bail_out:
close_sd_bsock(ua);

Expand All @@ -1337,32 +1340,29 @@ static void perform_move_operation(UAContext *ua, enum e_move_op operation)
free(visited_slot_list);
}

return;
return retval;
}

/*
* Import volumes from Import/Export Slots into normal Slots.
*/
int import_cmd(UAContext *ua, const char *cmd)
{
perform_move_operation(ua, VOLUME_IMPORT);
return 0;
return perform_move_operation(ua, VOLUME_IMPORT);
}

/*
* Export volumes from normal slots to Import/Export Slots.
*/
int export_cmd(UAContext *ua, const char *cmd)
{
perform_move_operation(ua, VOLUME_EXPORT);
return 0;
return perform_move_operation(ua, VOLUME_EXPORT);
}

/*
* Move volume from one slot to an other.
*/
int move_cmd(UAContext *ua, const char *cmd)
{
perform_move_operation(ua, VOLUME_MOVE);
return 0;
return perform_move_operation(ua, VOLUME_MOVE);
}

0 comments on commit 9d5f626

Please sign in to comment.