restarting engine fixes from willert
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine / HTTP / Restarter / Watcher.pm
index 3062dc6..b45c3da 100644 (file)
@@ -13,6 +13,7 @@ __PACKAGE__->mk_accessors(
       directory
       modified
       regex
+      follow_symlinks
       watch_list/
 );
 
@@ -47,8 +48,10 @@ sub watch {
 
     my @changes;
     my @changed_files;
+    
+    my $delay = ( defined $self->delay ) ? $self->delay : 1;
 
-    sleep $self->delay || 1;
+    sleep $delay if $delay > 0;
 
     eval { @changes = $self->modified->changed };
     if ($@) {
@@ -100,7 +103,9 @@ sub watch {
 sub _index_directory {
     my $self = shift;
 
-    my $dir   = $self->directory || die "No directory specified";
+    my $dir   = $self->directory;
+    die "No directory specified" if !$dir or ref($dir) && !@{$dir};
+
     my $regex = $self->regex     || '\.pm$';
     my %list;
 
@@ -118,9 +123,10 @@ sub _index_directory {
                 $cur_dir =~ s{/script/..}{};
                 $list{$cur_dir} = 1;
             },
+            follow_fast => $self->follow_symlinks ? 1 : 0,
             no_chdir => 1
         },
-        $dir
+        ref $dir eq 'ARRAY' ? @{$dir} : $dir
     );
     return \%list;
 }