- $state->{'slots'}->{$to_slot} = { %{ $state->{'slots'}->{$from_slot} } };
- $state->{'slots'}->{$from_slot}->{'state'} =
- Amanda::Changer::SLOT_EMPTY;
- $state->{'slots'}->{$from_slot}->{'device_status'} = undef;
- $state->{'slots'}->{$from_slot}->{'f_type'} = undef;
- $state->{'slots'}->{$from_slot}->{'label'} = undef;
- $state->{'slots'}->{$from_slot}->{'barcode'} = undef;
+ if ($from_slot ne $to_slot) {
+ my $f = $state->{'slots'}->{$from_slot};
+ my $t = $state->{'slots'}->{$to_slot};
+
+ $t->{'device_status'} = $f->{'device_status'};
+ $f->{'device_status'} = undef;
+
+ $t->{'state'} = $f->{'state'};
+ $f->{'state'} = Amanda::Changer::SLOT_EMPTY;
+
+ $t->{'f_type'} = $f->{'f_type'};
+ $f->{'f_type'} = undef;
+
+ $t->{'label'} = $f->{'label'};
+ $f->{'label'} = undef;
+
+ $t->{'barcode'} = $f->{'barcode'};
+ $f->{'barcode'} = undef;
+ }
+
+ # properly represent the unload operation, if it was performed
+ if (defined $in_drive) {
+ $state->{'slots'}->{$from_slot}->{'loaded_in'} = undef;
+ $state->{'slots'}->{$to_slot}->{'loaded_in'} = undef;
+
+ $state->{'drives'}->{$in_drive}->{'state'} =
+ Amanda::Changer::SLOT_EMPTY;
+ $state->{'drives'}->{$in_drive}->{'label'} = undef;
+ $state->{'drives'}->{$in_drive}->{'barcode'} = undef;
+ $state->{'drives'}->{$in_drive}->{'orig_slot'} = undef;
+ }