Handle case where event has been moved but db not updated. This can happen when using a transaction and the db goes away.

This commit is contained in:
Isaac Connor
2023-02-16 09:39:54 -05:00
parent c50209f66c
commit 07115422e7

View File

@@ -768,7 +768,17 @@ sub MoveTo {
}
my $OldStorage = $self->Storage(undef);
my $error = $self->CopyTo($NewStorage);
# In strange situations where commits don't happen, the files can be moved but the db hasn't been updated.
# So here's a special case test to fix that.
my ( $SrcPath ) = ( $self->Path() =~ /^(.*)$/ ); # De-taint
my ( $NewPath ) = ( $NewStorage->Path() =~ /^(.*)$/ ); # De-taint
my $error = '';
if (! -e $SrcPath and -e $NewPath) {
Warning("Event has already been moved, just updating the event.");
} else {
$error = $self->CopyTo($NewStorage);
}
if (!$error) {
# Succeeded in copying all files, so we may now update the Event.
$$self{StorageId} = $$NewStorage{Id};