Begin work on handling of non-email files in the production.

This commit is contained in:
Bradley M. Kuhn 2023-06-03 07:10:40 -07:00
parent beafad9259
commit eb37c59129

View file

@ -87,6 +87,26 @@ if ($GROUP_NAMES_BY_DIR{$GROUP} eq 'PRIVILEGE') {
my @CSV_OUTPUT_ROWS; my @CSV_OUTPUT_ROWS;
sub ProcessDocumentDirectory($$$);
sub ProcessDocumentDirectory($$$) {
my($rfp, $inputDocDir, $numberedOutputDir) = @_;
opendir(my $inputDH, $inputDocDir);
while (my $file = readdir $inputDH) {
next if $file =~ /^\s*\.\.?\s*$/;
my $fullFilePath = catfile($inputDocDir, $file);
if (-d $fullFilePath) {
ProcessDocumentDirectory($rfp, $fullFilePath, catfile($numberedOutputDir, $file));
} elsif (-f $fullFilePath) {
print " mv $fullFilePath ", catfile($numberedOutputDir, $file), "\n";
} else {
die("\"$fullFilePath\" is a strange file type, not handled!");
}
}
closedir $inputDH;
}
######################################################################
sub ProcessMailDir($$$) { sub ProcessMailDir($$$) {
my($rfp, $inputMailDir, $outputDir) = @_; my($rfp, $inputMailDir, $outputDir) = @_;
@ -150,6 +170,7 @@ sub ProcessMailDir($$$) {
closedir $mailDirFH; closedir $mailDirFH;
} }
} }
######################################################################
# Main Loop: # Main Loop:
opendir(my $topDH, $INPUT_TOPLEVEL_DIR); opendir(my $topDH, $INPUT_TOPLEVEL_DIR);
@ -167,11 +188,13 @@ while (my $rfp = readdir $topDH) {
die "regular file found where we expected a type in $typeName" unless -d $typeDirName; die "regular file found where we expected a type in $typeName" unless -d $typeDirName;
my $nativeOutputDirOneUp = File::Spec->rel2abs(catfile($OUTPUT_TOPLEVEL_DIR, 'native', $rfp, $bucketName)); my $nativeOutputDirOneUp = File::Spec->rel2abs(catfile($OUTPUT_TOPLEVEL_DIR, 'native', $rfp, $bucketName));
my $numberedOutputDir = File::Spec->rel2abs(catfile($OUTPUT_TOPLEVEL_DIR, 'numbered', $rfp, $bucketName, $typeName)); my $numberedOutputDir = File::Spec->rel2abs(catfile($OUTPUT_TOPLEVEL_DIR, 'numbered', $rfp, $bucketName, $typeName));
make_path($nativeOutputDirOneUp, { verbose => 1, mode => 0755 }); make_path($nativeOutputDirOneUp, { mode => 0755 });
make_path($numberedOutputDir, { verbose => 1, mode => 0755 }); make_path($numberedOutputDir, { mode => 0755 });
if ($typeName =~ /email/i) { if ($typeName =~ /email/i) {
ProcessMailDir($rfp, $typeDirName, $numberedOutputDir); ProcessMailDir($rfp, $typeDirName, $numberedOutputDir);
move($typeDirName, $nativeOutputDirOneUp); move($typeDirName, $nativeOutputDirOneUp);
} else {
ProcessDocumentDirectory($rfp, $typeDirName, $numberedOutputDir);
} }
} }
closedir $bucketDH; closedir $bucketDH;