don't redirect to /data/index needlessly
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 17 Jun 2010 14:26:30 +0000 (16:26 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 17 Jun 2010 14:26:30 +0000 (16:26 +0200)
This allow us to restart server and just load needed data on demand with
reload as opposed to first selecting active dataset and rest of the
stuff which we allready have in session.

lib/MojoFacets/Data.pm

index 8bf9aa3..c2283b8 100644 (file)
@@ -267,12 +267,14 @@ sub _loaded {
        if ( ! defined $loaded->{$path}->{$name} ) {
                warn "$path $name isn't loaded\n";
                $self->_load_path( $path );
-               $self->redirect_to('/data/index')
-                       unless defined $loaded->{$path}->{$name};
                if ( ! defined $loaded->{$path}->{stats} ) {
                        warn "rebuild stats for $path\n";
                        $loaded->{$path}->{stats} = __stats( $loaded->{$path}->{data}->{items} );
                }
+               if ( ! defined $loaded->{$path}->{$name} ) {
+                       warn "MISSING $name for $path\n";
+                       $self->redirect_to('/data/index')
+               }
        }
 
        $self->session( 'modified' => $loaded->{$path}->{modified} );
@@ -537,7 +539,6 @@ sub items {
        }
 
        my $path = $self->session('path');
-       $self->redirect_to('/data/index') unless defined $loaded->{ $path };
 
        my @columns = $self->_param_array('columns');
        $self->redirect_to('/data/columns') unless @columns;