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

- improved search ignoring dot-files

- improved search by extracting regex
- added time output
- disabling STDOUT caching to improve progress view
parent 1518ead1
No related branches found
No related tags found
No related merge requests found
......@@ -642,15 +642,20 @@ sub parse_iexml($filename, $recovery_flag) {
# returns count of subdirs of $dir
sub searching_relevant_subdirs ($dir) {
my $first_two_levels_of_dirs = 0;
my $rx_dir = qr{^\Q$dir\E/?};
###
my $wanted_twolevel_dircount = sub {
my $relpath = $File::Find::name;
$relpath =~ s{^\Q$dir\E/?}{};
my $depth = File::Spec->splitdir($relpath);
if (/^\.[A-Za-z0-9]/) { # ignore dot-dirs
$File::Find::prune = 1;
} else {
my $relpath = $File::Find::name;
$relpath =~ s{$rx_dir}{};
my $depth = File::Spec->splitdir($relpath);
$depth >= 2
and $File::Find::prune = 1;
if (-d $_) {$first_two_levels_of_dirs++;}
$depth >= 2
and $File::Find::prune = 1;
if (-d $_) {$first_two_levels_of_dirs++;}
}
};
###
find($wanted_twolevel_dircount, $dir);
......@@ -659,6 +664,7 @@ sub searching_relevant_subdirs ($dir) {
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 $rx_dir = qr{^\Q$dir\E/?};
###
my $dircount = 0;
my $wanted_process_sip = sub {
......@@ -667,17 +673,21 @@ sub searching_relevant_ie_files ($dir, $tmp_ies_unsorted_file, $first_two_levels
my $file = $File::Find::name;
# fake name to ue alphabetical sort
my $fakeversion = sprintf("%05i", $version);
$file =~ s/V(\d+)-IE/V$fakeversion-IE/;
$file =~ s/V\d+-IE/V$fakeversion-IE/;
$tmp_ies_unsorted_file->append($file . "\n");
$dircount++;
$File::Find::prune = 1;
}
elsif (-d) {
my $relpath = $File::Find::name;
$relpath =~ s{^\Q$dir\E/?}{};
my $depth = File::Spec->splitdir($relpath);
if ($depth <= 2) {
print $progressbar->report("find IE files: %40b ETA: %E \r", $dircount);
if (/^\.[A-Za-z0-9]/) { # ignore dot-dirs
$File::Find::prune = 1;
} else {
my $relpath = $File::Find::name;
$relpath =~ s{$rx_dir}{};
my $depth = File::Spec->splitdir($relpath);
if ($depth <= 2) {
print $progressbar->report("find IE files: %40b ETA: %E \r", $dircount);
}
}
}
return;
......@@ -694,9 +704,12 @@ sub searching_ie_files ($dirs_ref, $tmp_ies_unsorted_file) {
my $maxpass=scalar @dirs;
foreach my $dir (@dirs) {
$pass++;
my $begin_time = time;
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 '$dir') ";
my $end_time = time;
my $diff_time = $end_time - $begin_time;
say "found $count IEs in pass $pass/$maxpass (dir '$dir') in $diff_time s ";
$cnt_unsorted_files+=$count;
}
say "\r ";
......@@ -752,6 +765,9 @@ if (defined $flag_sqldump) {
if ($#ARGV_tail < 0) {
die "you need at least a directory as argument\n";
}
my $old_stdout = select(STDOUT);
$| = 1;
select($old_stdout);
if (
(! defined $flag_continue)
......@@ -792,7 +808,7 @@ my $dbh = DBI->connect("dbi:SQLite:dbname=$db_filename", "", "", {
RaiseError => 1,
sqlite_unicode => 1,
}) or die "could not connect to database (file '$db_filename')", $DBI::errstr;
my $begin_time = time;
my $plans = prepare_addsql( $dbh);
while (<$fh_unsorted_IEs>) {
chomp;
......@@ -816,7 +832,9 @@ while (<$fh_unsorted_IEs>) {
}
$dbh->disconnect or warn("disconnecting problems, ", $dbh->errstr);
say "\rprocessed $count uniq IEs ";
my $end_time = time;
my $diff_time = $end_time - $begin_time;
say "\rprocessed $count uniq IEs in $diff_time s ";
say "";
1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment