Bladeren bron

make migrate3 run cleanly

George Baugh 3 jaren geleden
bovenliggende
commit
b1e8047cc0
2 gewijzigde bestanden met toevoegingen van 7 en 4 verwijderingen
  1. 6 3
      bin/migrate3.pl
  2. 1 1
      lib/Trog/DataModule.pm

+ 6 - 3
bin/migrate3.pl

@@ -32,17 +32,20 @@ my $conf = Trog::Config::get();
 my $search_info = Trog::Data->new($conf);
 
 my @all = $search_info->get( raw => 1, limit => 0 );
-
 #TODO add in the various things we need to data
 foreach my $post (@all) {
-    if ( $post->{form} eq 'series.tx' ) {
+    if ( defined $post->{form} && $post->{form} eq 'series.tx' ) {
         $post->{tiled} = scalar(grep { $_ eq $post->{local_href} } qw{/files /audio /video /image /series /about});
     }
+    if (!defined $post->{visibility}) {
+        $post->{visibility} = 'public' if grep { $_ eq 'public' } @{$post->{tags}};
+        $post->{visibility} = 'private' if grep { $_ eq 'private' } @{$post->{tags}};
+        $post->{visibility} = 'unlisted' if grep { $_ eq 'unlisted' } @{$post->{tags}};
+    }
     # Otherwise re-save the posts with is_video etc
     $search_info->add($post);
 }
 
-
 # Rebuild the index
 Trog::SQLite::TagIndex::build_index($search_info);
 Trog::SQLite::TagIndex::build_routes($search_info);

+ 1 - 1
lib/Trog/DataModule.pm

@@ -326,7 +326,7 @@ sub _process ($post) {
     $post->{is_video}   = 1 if $post->{content_type} =~ m/^video\//;
     $post->{is_audio}   = 1 if $post->{content_type} =~ m/^audio\//;
     $post->{is_image}   = 1 if $post->{content_type} =~ m/^image\//;
-    $post->{is_profile} = 1 if grep {$_ eq 'about' } @{$post->{tags}};
+    $post->{is_profile} = 1 if grep { $_ eq 'about' } @{$post->{tags}};
 
     return $post;
 }