--- lib/Arh/Model/Picture.pm 2007/11/29 11:48:39 5 +++ lib/Arh/Model/Picture.pm 2007/11/29 12:36:51 6 @@ -3,6 +3,8 @@ package Arh::Model::Picture; use Jifty::DBI::Schema; +use File::Find; +use Data::Dump qw/dump/; use Arh::Record schema { @@ -16,7 +18,8 @@ column filename => label is _("Picture filename"), is required, - is indexed; + is indexed, + is unique; column type => label is _("Type of picture"), @@ -31,5 +34,23 @@ sub since { '0.0.3' } +sub all_filenames { + + my @files; + my $path = Jifty::Util->app_root . '/share/web/static/pics'; + + warn "## path = $path"; + + find({ wanted => sub { + my $f = $File::Find::name; + return unless -f $f; + push @files, $_; + }, follow => 0 }, $path); + + warn "## all_filenames = ",dump( @files ); + + return @files; +} + 1;