Do no commit on error as it releases locks. Add better storage loading error handling

This commit is contained in:
Isaac Connor 2021-10-25 09:44:20 -04:00
parent a258567c16
commit 522f8dd5ba
1 changed files with 11 additions and 9 deletions

View File

@ -359,10 +359,14 @@ sub checkFilter {
} # end if AutoDelete
if ($filter->{AutoMove}) {
my $NewStorage = new ZoneMinder::Storage($filter->{AutoMoveTo});
my $NewStorage = ZoneMinder::Storage->find_one(Id=>$filter->{AutoMoveTo});
if ($NewStorage) {
Info("Moving event $Event->{Id} to datastore $filter->{AutoMoveTo}");
$_ = $Event->MoveTo($NewStorage);
Error($_) if $_;
} else {
Error("No storage area found for move to operation. AutoMoveTo was $$filter{AutoMoveTo}");
}
}
if ($filter->{AutoCopy}) {
# Copy To is different from MoveTo in that it JUST copies the files
@ -372,11 +376,9 @@ sub checkFilter {
Info("Copying event $Event->{Id} to datastore $filter->{AutoCopyTo}");
$_ = $Event->CopyTo($NewStorage);
if ($_) {
$ZoneMinder::Database::dbh->commit();
Error($_);
} else {
$Event->save({SecondaryStorageId=>$$NewStorage{Id}});
$ZoneMinder::Database::dbh->commit();
}
} else {
Error("No storage area found for copy to operation. AutoCopyTo was $$filter{AutoCopyTo}");