Skip to content

Commit

Permalink
scanspool: Detect directories with all-digit name
Browse files Browse the repository at this point in the history
Recognize timehash and timecaf directories, but still do not parse articles.

see #192
  • Loading branch information
Julien-Elie committed Jan 20, 2024
1 parent 845caa2 commit 7e13229
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
8 changes: 5 additions & 3 deletions doc/pod/news.pod
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ as a format like C<Jul 29 04:15:01> was expected.

=item *

B<scanspool> now detects empty files in a tradspool news spool, correctly
parses continuation lines in header fields, and can automatically remove
articles reported to have a problem (when run with the new B<-r> flag).
B<scanspool> now detects empty files in a tradspool news spool, directories
with an all-digit component (which may conflict with a possible file with
the same name), correctly parses continuation lines in header fields, and can
automatically remove articles reported to have a problem (when run with the
new B<-r> flag).

=item *

Expand Down
13 changes: 6 additions & 7 deletions doc/pod/scanspool.pod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ It will scan the F<active> file as well as all articles in the spool and
report on the errors it encounters. As this may take a while, using the
B<-v> switch is recommended to see how far the program has progressed.

B<scanspool> will skip any file named other than just all-digits when treating
the contents of the news spool.

First, B<scanspool> scans the F<active> file, noting problems such as:

=over 4
Expand Down Expand Up @@ -63,6 +66,9 @@ are in a newsgroup to which they do not belong.

=back

B<scanspool> will also complain about directories with an all-digit component
as they may conflict with a possible file with the same name.

B<scanspool> understands aliased newsgroups. Thus, if an article is posted
to foo.old.name that is aliased to foo.bar, it will be expected to
be found under foo.bar and not foo.old.name.
Expand Down Expand Up @@ -159,13 +165,6 @@ Verbose messages start with a tab.

=back

=head1 BUGS

B<scanspool> is unable to detect and properly deal with spool formats
other than tradspool. However, if the files that store your articles
are named other than just all-digits, they will simply be skipped
(and your F<active> is still checked).

=head1 HISTORY

B<scanspool> was written by Landon Curt Noll (chongo was here /\../\).
Expand Down
21 changes: 20 additions & 1 deletion frontends/scanspool.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ use strict;
# - are in a directory for which there is no newsgroup in the active file
# - are in a newsgroup to which they do not belong
#
# scanspool will also complain about directories with an all-digit component
# as they may conflict with a possible file with the same name.
#
# scanspool understands aliased groups. Thus, if an article is posted
# to foo.old.name that is aliased to foo.bar, it will be expected to
# be found under foo.bar and not foo.old.name.
Expand Down Expand Up @@ -342,7 +345,8 @@ sub check_spool {
#
if (
!open $FINDFILE, '-|',
"find . \\( -type f -o -type l \\) -name '[0-9]*' -print 2>&1"
"find . \\( -type d -o -type f -o -type l \\) -name '[0-9]*' "
. "-print 2>&1"
) {
fatal(3, "cannot start find in $spool");
}
Expand All @@ -369,6 +373,21 @@ sub check_spool {
# skip if not a numeric basename
next if ($filename !~ m:/\d+$:o);

# skip timehash and timecaf spools
next
if $filename =~ /^time-\d\d\/\d\d/
or $filename =~ /^time-\d\d\/..\/\d\d/
or $filename =~ /^timecaf-\d\d\/\d\d/;

if (-d "$filename") {
problem(
"WARNING:",
"$filename: directory with an all-digit component",
"(may conflict with a possible file with the same name)"
);
next;
}

# get the article's newsgroup name (based on its path from $spool)
$artgrp = $filename;
$artgrp =~ s#/\d+$##o;
Expand Down

0 comments on commit 7e13229

Please sign in to comment.