Skip to content
Snippets Groups Projects
Commit d6498093 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- refactoring, extracted searching_relevant_subdirs()

- refactoring, extracted searching_relevant_ie_files()
parent 55142eae
No related branches found
No related tags found
No related merge requests found
......@@ -394,13 +394,7 @@ sub check_if_db_conform ($string, $filename) {
}
}
sub searching_ie_files ($dirs_ref, $tmp_ies_unsorted_file) {
my $cnt_unsorted_files = 0;
my $pass = 0;
my @dirs = @{ $dirs_ref };
my $maxpass=scalar @dirs;
foreach my $dir (@dirs) {
$pass++;
sub searching_relevant_subdirs ($dir) {
my $first_two_levels_of_dirs = 0;
###
my $wanted_twolevel_dircount = sub {
......@@ -414,9 +408,13 @@ sub searching_ie_files ($dirs_ref, $tmp_ies_unsorted_file) {
};
###
find($wanted_twolevel_dircount, $dir);
return $first_two_levels_of_dirs;
}
sub searching_relevant_ie_files ($dir, $tmp_ies_unsorted_file, $first_two_levels_of_dirs) {
my $progressbar = Time::Progress->new(min => 0, max => $first_two_levels_of_dirs, smoothing => 1);
my $dircount = 0;
###
my $dircount = 0;
my $wanted_process_sip = sub {
if (-f && m/V(\d+)-IE\d+\.xml$/) {
my $version = $1;
......@@ -425,7 +423,7 @@ sub searching_ie_files ($dirs_ref, $tmp_ies_unsorted_file) {
my $fakeversion = sprintf("%05i", $version);
$file =~ s/V(\d+)-IE/V$fakeversion-IE/;
$tmp_ies_unsorted_file->append($file . "\n");
$cnt_unsorted_files++;
$dircount++;
$File::Find::prune = 1;
}
elsif (-d) {
......@@ -433,16 +431,29 @@ sub searching_ie_files ($dirs_ref, $tmp_ies_unsorted_file) {
$relpath =~ s{^\Q$dir\E/?}{};
my $depth = File::Spec->splitdir($relpath);
if ($depth <= 2) {
print $progressbar->report("find IE files (pass $pass/$maxpass: %40b ETA: %E \r", $dircount++);
print $progressbar->report("find IE files: %40b ETA: %E \r", $dircount);
}
}
return;
};
###
find($wanted_process_sip, $dir);
say "";
return $dircount;
}
sub searching_ie_files ($dirs_ref, $tmp_ies_unsorted_file) {
my $cnt_unsorted_files = 0;
my $pass = 0;
my @dirs = @{ $dirs_ref };
my $maxpass=scalar @dirs;
foreach my $dir (@dirs) {
$pass++;
my $first_two_levels_of_dirs = searching_relevant_subdirs($dir);
my $count = searching_relevant_ie_files($dir, $tmp_ies_unsorted_file, $first_two_levels_of_dirs);
say "found $count IEs in pass $pass/$maxpass ($dir) ";
$cnt_unsorted_files+=$count;
}
say "\r ";
return $cnt_unsorted_files;
}
......@@ -507,7 +518,6 @@ if (0==@ARGV_tail ){
my @dirs;
while (@ARGV_tail > 0) {
my $dir = shift @ARGV_tail;
if (defined $dir && -d "$dir") {
push @dirs, $dir;
}
......@@ -532,8 +542,7 @@ while (<$fh_unsorted_IEs>) {
write_addsql($dbh, $ret);
$dbh->disconnect or warn("disconnecting problems, ", $dbh->errstr);
}
say "";
say "processed $count uniq IEs";
say "\rprocessed $count uniq IEs ";
say "";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment