From: Errietta Kostala Date: Wed, 27 Aug 2014 08:56:02 +0000 (+0100) Subject: Fix cleaned up config files code X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=555776fb2ef19573dc44f2dc5517b0020f5e7d4e;p=scpubgit%2FApp-SCS.git Fix cleaned up config files code --- diff --git a/lib/App/SCS/PageSet.pm b/lib/App/SCS/PageSet.pm index daac00e..d276840 100644 --- a/lib/App/SCS/PageSet.pm +++ b/lib/App/SCS/PageSet.pm @@ -64,12 +64,10 @@ sub get { sub _config_files_for { my ($self, $path) = @_; - my @files = (); my @dir_parts = io->dir($path)->splitdir; - my @dirs = map io->dir('')->catdir(@dir_parts[1..$_]), 1..($#dir_parts - 1); - return grep +($_->file and not $_->empty), + return grep +($_->is_file and $_->exists and not $_->empty), map $self->_top_dir->catfile("${_}.conf"), @dirs; } @@ -77,8 +75,8 @@ sub _inflate { my ($self, $type, $path, $io) = @_; (my $cache_name = $io->name) =~ s/\/([^\/]+)$/\/.htcache.$1.json/; my $cache = io($cache_name); - my $config_files = $self->_config_files_for($path); - my $max_stat = max map $_->mtime, $io, @$config_files; + my @config_files = $self->_config_files_for($path); + my $max_stat = max map $_->mtime, $io, @config_files; if (-f $cache_name) { if ($cache->mtime >= $max_stat) { @@ -94,7 +92,7 @@ sub _inflate { my $extracted = $self->${\"_extract_from_${type}"}($raw); my $jsony = JSONY->new; - my $config = reduce { merge($a, $jsony->load($b->all)) } [], @$config_files; + my $config = reduce { merge($a, $jsony->load($b->all)) } [], @config_files; $extracted->{plugins} = pond_read_datum('[' . $extracted->{plugins} . ']');