Skip to content

Commit c262a99

Browse files
committed
Add eval/hgetall to clean db to remove corrupt entries
1 parent 68f753e commit c262a99

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/LANraragi/Utils/Database.pm

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,18 @@ sub clean_database {
155155
my $unlinked_arcs = 0;
156156

157157
foreach my $id (@keys) {
158-
my $file = $redis->hget( $id, "file" );
159158

159+
# Check if the DB entry is correct
160+
eval { $redis->hgetall( $id ); };
161+
162+
if ($@) {
163+
$redis->del($id);
164+
$deleted_arcs++;
165+
next;
166+
}
167+
168+
# Check if the linked file exists
169+
my $file = $redis->hget( $id, "file" );
160170
unless ( -e $file ) {
161171
$redis->del($id);
162172
$deleted_arcs++;

0 commit comments

Comments
 (0)