diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b58ebb..7f8c014 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file. - Add progress bar +### Changed + +- Limit "Skipped" output to only summary + ## [3.0.0] ### Changed diff --git a/simplify_static_dir.pl b/simplify_static_dir.pl index 0dbdff3..2af9ed4 100755 --- a/simplify_static_dir.pl +++ b/simplify_static_dir.pl @@ -142,24 +142,6 @@ MAIN: { # outright skip directories (don't report skip) return if -d $File::Find::name; - # limit to or exclude file patterns specified by `-m' or `-M', - # respectively - - # truth table - # -m matches | -M is used & matches | !return? - # 0 | 0 | 0 - # 0 | 1 | 0 - # 1 | 0 | 1 - # 1 | 1 | 0 - # note: m// will match everything - unless ($File::Find::name =~ m/$opts{m}/ and - !(length $opts{M} and $File::Find::name =~ m/$opts{M}/)) { - - print STDERR "Skipping path `$File::Find::name'\n" - if $opts{v}; - return; - } - # skip non-existent files and links unless (-f $File::Find::name && ! -l $File::Find::name) { return; @@ -172,6 +154,36 @@ MAIN: { scalar @files if $opts{v}; + # Limit to or exclude file patterns specified by `-m' or `-M', respectively + # + # Truth table: + # -m matches | -M is used & matches | !return? + # 0 | 0 | 0 + # 0 | 1 | 0 + # 1 | 0 | 1 + # 1 | 1 | 0 + # note: m// will match everything + my $file_ct_before_filter = scalar @files; + @files = grep { + $_->{rel_name} =~ $opts{m} + } @files; + if ($file_ct_before_filter != scalar @files) { + printf STDERR " (%d files filtered by -m rule)", + $file_ct_before_filter - scalar @files + if $opts{v}; + } + if (length $opts{M}) { + $file_ct_before_filter = scalar @files; + @files = grep { + not $_->{rel_name} =~ $opts{M} + } @files; + if ($file_ct_before_filter != scalar @files) { + printf STDERR " (%d files filtered by -M rule)", + $file_ct_before_filter - scalar @files + if $opts{v}; + } + } + # Shortcut: Only generate hashes and inspect files that do not have a # unique size. The reasoning being that file sizes do not match, there's no # possible way those two files can have the same contents. @@ -505,8 +517,10 @@ require Cwd; sub new { my $class = shift; + my $rel_name = shift; my $self = bless { - name => Cwd::abs_path(shift), + rel_name => $rel_name, + name => Cwd::abs_path($rel_name), }, $class; (@{$self}{qw/ dev ino mode nlink uid gid rdev size atime mtime ctime blksize blocks /})