From 9eae37d52e5aca942693dbb31aab63b70784e38c Mon Sep 17 00:00:00 2001 From: Francesc Guasch Date: Tue, 26 May 2026 12:17:39 +0200 Subject: [PATCH] fix: properly check network already added issue #2335 --- lib/Ravada.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Ravada.pm b/lib/Ravada.pm index 2e455c630..c33b1a058 100644 --- a/lib/Ravada.pm +++ b/lib/Ravada.pm @@ -231,10 +231,13 @@ sub _add_internal_network($self) { my ($found) = $sth->fetchrow; return if $found; - $sth = $CONNECTOR->dbh->prepare("SELECT * FROM networks WHERE name like 'internal%'"); + my %done; + $sth = $CONNECTOR->dbh->prepare("SELECT * FROM networks"); $sth->execute(); - ($found) = $sth->fetchrow; - return if $found; + while ( my $row = $sth->fetchrow_hashref) { + return if $row->{name} =~ /^internal/; + $done{$row->{address}}++; + }; my @cmd = ("ip","route"); my ($in, $out, $err); @@ -247,11 +250,10 @@ sub _add_internal_network($self) { ." VALUES(?,?,?,1,0)" ); my $n=0; - my %done; for my $net (split /\n/,$out) { next if $net =~ /dev virbr/; my ($address) = $net =~ m{(^[\d\.]+/\d+)}; - next if !$address || $done{address}++; + next if !$address || $done{$address}++; $sth->execute("internal$n",$address, ++$n+1); }