Unverified Commit 18e03550 authored by IKEDA Soji's avatar IKEDA Soji Committed by GitHub
Browse files

Merge pull request #908 from racke/pr/arc-improve-logging by racke

Improve logging of archive errors due to possible permission problems 
parents d2a043dd 4839487e
...@@ -150,7 +150,13 @@ sub select_archive { ...@@ -150,7 +150,13 @@ sub select_archive {
my $deleted_directory = $arc_directory . '/deleted'; my $deleted_directory = $arc_directory . '/deleted';
my $dh; my $dh;
return undef unless opendir $dh, $directory; unless (opendir $dh, $directory) {
if ( -d $directory ) {
$log->syslog('err', 'Failed to open archive directory %s: %s',
$directory, $ERRNO);
}
return;
}
closedir $dh; closedir $dh;
undef $self->{_metadatas}; undef $self->{_metadatas};
...@@ -209,9 +215,16 @@ sub html_fetch { ...@@ -209,9 +215,16 @@ sub html_fetch {
return undef unless $self->{arc_directory}; return undef unless $self->{arc_directory};
return undef unless $options{file}; return undef unless $options{file};
my $handle = my $html_file = $self->{arc_directory} . '/' . $options{file};
IO::File->new($self->{arc_directory} . '/' . $options{file}, '<'); my $handle = IO::File->new($html_file, '<');
return undef unless $handle;
unless ($handle) {
if (-f $html_file) {
$log->syslog('err', 'Failed to open archive file %s: %s',
$html_file, $ERRNO);
}
return undef;
}
my $metadata = {}; # May be empty. my $metadata = {}; # May be empty.
while (<$handle>) { while (<$handle>) {
...@@ -303,8 +316,9 @@ sub html_next { ...@@ -303,8 +316,9 @@ sub html_next {
unless ($self->{_html_metadatas}) { unless ($self->{_html_metadatas}) {
my $dh; my $dh;
unless (opendir $dh, $self->{arc_directory}) { unless (opendir $dh, $self->{arc_directory}) {
die sprintf 'Cannot open dir %s: %s', $self->{arc_directory}, $log->syslog('err', 'Cannot open dir %s: %s', $self->{arc_directory},
$ERRNO; $ERRNO);
return undef;
} }
$self->{_html_metadatas} = [ $self->{_html_metadatas} = [
sort _cmp_numeric grep { sort _cmp_numeric grep {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment