don't move event if there are no files. Add some more debug
parent
29140a3012
commit
095f4614da
|
@ -437,7 +437,7 @@ sub delete_files {
|
||||||
Error("S3 bucket $bucket not found.");
|
Error("S3 bucket $bucket not found.");
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
if ( $bucket->delete_key( $event_path ) ) {
|
if ( $bucket->delete_key($event_path) ) {
|
||||||
$deleted = 1;
|
$deleted = 1;
|
||||||
} else {
|
} else {
|
||||||
Error("Failed to delete from S3:".$s3->err . ": " . $s3->errstr);
|
Error("Failed to delete from S3:".$s3->err . ": " . $s3->errstr);
|
||||||
|
@ -456,7 +456,7 @@ sub delete_files {
|
||||||
Debug("Deleting files for Event $$event{Id} from $storage_path/$link_path.");
|
Debug("Deleting files for Event $$event{Id} from $storage_path/$link_path.");
|
||||||
if ( $link_path ) {
|
if ( $link_path ) {
|
||||||
( $link_path ) = ( $link_path =~ /^(.*)$/ ); # De-taint
|
( $link_path ) = ( $link_path =~ /^(.*)$/ ); # De-taint
|
||||||
unlink( $storage_path.'/'.$link_path ) or Error( "Unable to unlink '$storage_path/$link_path': $!" );
|
unlink($storage_path.'/'.$link_path) or Error( "Unable to unlink '$storage_path/$link_path': $!" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} # end sub delete_files
|
} # end sub delete_files
|
||||||
|
@ -466,7 +466,7 @@ sub Storage {
|
||||||
$_[0]{Storage} = $_[1];
|
$_[0]{Storage} = $_[1];
|
||||||
}
|
}
|
||||||
if ( ! $_[0]{Storage} ) {
|
if ( ! $_[0]{Storage} ) {
|
||||||
$_[0]{Storage} = new ZoneMinder::Storage( $_[0]{StorageId} );
|
$_[0]{Storage} = new ZoneMinder::Storage($_[0]{StorageId});
|
||||||
}
|
}
|
||||||
return $_[0]{Storage};
|
return $_[0]{Storage};
|
||||||
}
|
}
|
||||||
|
@ -630,6 +630,10 @@ Debug("Files to move @files");
|
||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
my @files = glob("$OldPath/*");
|
my @files = glob("$OldPath/*");
|
||||||
|
if ( ! @files ) {
|
||||||
|
$ZoneMinder::Database::dbh->commit();
|
||||||
|
return "No files to move.";
|
||||||
|
}
|
||||||
|
|
||||||
for my $file (@files) {
|
for my $file (@files) {
|
||||||
next if $file =~ /^\./;
|
next if $file =~ /^\./;
|
||||||
|
@ -659,8 +663,10 @@ Debug("Files to move @files");
|
||||||
$ZoneMinder::Database::dbh->commit();
|
$ZoneMinder::Database::dbh->commit();
|
||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
|
Debug("Committing");
|
||||||
$ZoneMinder::Database::dbh->commit();
|
$ZoneMinder::Database::dbh->commit();
|
||||||
$self->delete_files( $OldStorage );
|
$self->delete_files( $OldStorage );
|
||||||
|
Debug("Done deleting files, returning");
|
||||||
return $error;
|
return $error;
|
||||||
} # end sub MoveTo
|
} # end sub MoveTo
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue