Lines 115-138
Deletes all records where the actual file is not found.
Link Here
|
115 |
|
115 |
|
116 |
Supports a keep_record hash parameter to do a check only. |
116 |
Supports a keep_record hash parameter to do a check only. |
117 |
|
117 |
|
118 |
Returns the number of missing files (and/or deleted records). |
118 |
Return value: see delete. |
119 |
|
119 |
|
120 |
=cut |
120 |
=cut |
121 |
|
121 |
|
122 |
sub delete_missing { |
122 |
sub delete_missing { |
123 |
my ( $self, $params ) = @_; |
123 |
my ( $self, $params ) = @_; |
124 |
$self = Koha::UploadedFiles->new if !ref($self); # handle class call |
124 |
$self = Koha::UploadedFiles->new if !ref($self); # handle class call |
125 |
my $cnt = 0; |
125 |
my $rv = 0; |
126 |
while( my $row = $self->next ) { |
126 |
while( my $row = $self->next ) { |
127 |
if( my $file = $row->full_path ) { |
127 |
if( my $file = $row->full_path ) { |
128 |
next if -e $file; |
128 |
next if -e $file; |
|
|
129 |
if( $params->{keep_record} ) { |
130 |
$rv++; |
131 |
next; |
132 |
} |
129 |
# We are passing keep_file since we already know that the file |
133 |
# We are passing keep_file since we already know that the file |
130 |
# is missing and we do not want to see the warning |
134 |
# is missing and we do not want to see the warning |
131 |
$row->delete({ keep_file => 1 }) if !$params->{keep_record}; |
135 |
my $delete = $row->delete({ keep_file => 1 }) // -1; |
132 |
$cnt++; |
136 |
# Apply the same logic as in delete for the return value |
|
|
137 |
$rv = ( $delete < 0 || $rv < 0 ) ? -1 : ( $rv + $delete ); |
133 |
} |
138 |
} |
134 |
} |
139 |
} |
135 |
return $cnt; |
140 |
return $rv; |
136 |
} |
141 |
} |
137 |
|
142 |
|
138 |
=head3 search_term |
143 |
=head3 search_term |
139 |
- |
|
|