Jobs: include existing types in state file regex for deletion

otherwise, we cannot correctly match types that contain a hyphen,
since the id itself can also contain those.

creating a regex where the first part is the concrete allowed
types followed by a hyphen + id can also match those.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dominik Csapak 2023-01-17 12:46:56 +01:00 committed by Thomas Lamprecht
parent 63d74bb632
commit a1c51a74ca

View File

@ -324,7 +324,10 @@ sub synchronize_job_states_with_config {
} }
} }
PVE::Tools::dir_glob_foreach($state_dir, '(.*?)-(.*).json', sub { my $valid_types = PVE::Job::Registry->lookup_types();
my $type_regex = join("|", $valid_types->@*);
PVE::Tools::dir_glob_foreach($state_dir, "(${type_regex})-(.*).json", sub {
my ($path, $type, $id) = @_; my ($path, $type, $id) = @_;
if (!defined($data->{ids}->{$id})) { if (!defined($data->{ids}->{$id})) {