mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-04-21 06:05 am

[dw-free] Allow importing of your journal from another LiveJournal-based site.

[commit: http://hg.dwscoalition.org/dw-free/rev/31f6db459a34]

http://bugs.dwscoalition.org/show_bug.cgi?id=114

Fix temporary failures. These should now show up in inboxes around the world
for great edification of programmers puzzling.

Patch by [staff profile] mark.

Files modified:
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Bio.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Entries.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/FriendGroups.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Friends.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Tags.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Userpics.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Verify.pm
--------------------------------------------------------------------------------
diff -r 9bff62aa448e -r 31f6db459a34 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Bio.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Bio.pm	Tue Apr 21 05:47:37 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Bio.pm	Tue Apr 21 06:05:50 2009 +0000
@@ -24,18 +24,18 @@ use DW::Worker::ContentImporter::Local::
 
 sub work {
     my ( $class, $job ) = @_;
+    my $opts = $job->arg;
+    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
 
-    eval { try_work( $class, $job ); };
-    if ( $@ ) {
-        warn "Failure running job: $@\n";
-        return $class->temp_fail( $job, 'Failure running job: %s', $@ );
+    eval { try_work( $class, $job, $opts, $data ); };
+    if ( my $msg = $@ ) {
+        $msg =~ s/\r?\n/ /gs;
+        return $class->temp_fail( $data, 'lj_bio', $job, 'Failure running job: %s', $msg );
     }
 }
 
 sub try_work {
-    my ( $class, $job ) = @_;
-    my $opts = $job->arg;
-    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
+    my ( $class, $job, $opts, $data ) = @_;
 
     # failure wrappers for convenience
     my $fail      = sub { return $class->fail( $data, 'lj_bio', $job, @_ ); };
diff -r 9bff62aa448e -r 31f6db459a34 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm	Tue Apr 21 05:47:37 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm	Tue Apr 21 06:05:50 2009 +0000
@@ -30,18 +30,18 @@ our $COMMENTS_FETCH_BODY = 1000;
 
 sub work {
     my ( $class, $job ) = @_;
+    my $opts = $job->arg;
+    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
 
-    eval { try_work( $class, $job ); };
-    if ( $@ ) {
-        warn "Failure running job: $@\n";
-        return $class->temp_fail( $job, 'Failure running job: %s', $@ );
+    eval { try_work( $class, $job, $opts, $data ); };
+    if ( my $msg = $@ ) {
+        $msg =~ s/\r?\n/ /gs;
+        return $class->temp_fail( $data, 'lj_comments', $job, 'Failure running job: %s', $msg );
     }
 }
 
 sub try_work {
-    my ( $class, $job ) = @_;
-    my $opts = $job->arg;
-    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
+    my ( $class, $job, $opts, $data ) = @_;
     my $begin_time = [ gettimeofday() ];
 
     # we know that we can potentially take a while, so budget a few hours for
diff -r 9bff62aa448e -r 31f6db459a34 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Entries.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Entries.pm	Tue Apr 21 05:47:37 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Entries.pm	Tue Apr 21 06:05:50 2009 +0000
@@ -25,11 +25,13 @@ use DW::Worker::ContentImporter::Local::
 
 sub work {
     my ( $class, $job ) = @_;
+    my $opts = $job->arg;
+    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
 
-    eval { try_work( $class, $job ); };
-    if ( $@ ) {
-        warn "Failure running job: $@\n";
-        return $class->temp_fail( $job, 'Failure running job: %s', $@ );
+    eval { try_work( $class, $job, $opts, $data ); };
+    if ( my $msg = $@ ) {
+        $msg =~ s/\r?\n/ /gs;
+        return $class->temp_fail( $data, 'lj_entries', $job, 'Failure running job: %s', $msg );
     }
 
     # FIXME: temporary hack to reclaim memory when we have imported entries
@@ -37,9 +39,7 @@ sub work {
 }
 
 sub try_work {
-    my ( $class, $job ) = @_;
-    my $opts = $job->arg;
-    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
+    my ( $class, $job, $opts, $data ) = @_;
     my $begin_time = [ gettimeofday() ];
 
     # we know that we can potentially take a while, so budget a few hours for
diff -r 9bff62aa448e -r 31f6db459a34 cgi-bin/DW/Worker/ContentImporter/LiveJournal/FriendGroups.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/FriendGroups.pm	Tue Apr 21 05:47:37 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/FriendGroups.pm	Tue Apr 21 06:05:50 2009 +0000
@@ -25,18 +25,18 @@ use DW::Worker::ContentImporter::Local::
 
 sub work {
     my ( $class, $job ) = @_;
+    my $opts = $job->arg;
+    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
 
-    eval { try_work( $class, $job ); };
-    if ( $@ ) {
-        warn "Failure running job: $@\n";
-        return $class->temp_fail( $job, 'Failure running job: %s', $@ );
+    eval { try_work( $class, $job, $opts, $data ); };
+    if ( my $msg = $@ ) {
+        $msg =~ s/\r?\n/ /gs;
+        return $class->temp_fail( $data, 'lj_friendgroups', $job, 'Failure running job: %s', $msg );
     }
 }
 
 sub try_work {
-    my ( $class, $job ) = @_;
-    my $opts = $job->arg;
-    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
+    my ( $class, $job, $opts, $data ) = @_;
 
     # failure wrappers for convenience
     my $fail      = sub { return $class->fail( $data, 'lj_friendgroups', $job, @_ ); };
diff -r 9bff62aa448e -r 31f6db459a34 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Friends.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Friends.pm	Tue Apr 21 05:47:37 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Friends.pm	Tue Apr 21 06:05:50 2009 +0000
@@ -23,18 +23,18 @@ use Carp qw/ croak confess /;
 
 sub work {
     my ( $class, $job ) = @_;
+    my $opts = $job->arg;
+    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
 
-    eval { try_work( $class, $job ); };
-    if ( $@ ) {
-        warn "Failure running job: $@\n";
-        return $class->temp_fail( $job, 'Failure running job: %s', $@ );
+    eval { try_work( $class, $job, $opts, $data ); };
+    if ( my $msg = $@ ) {
+        $msg =~ s/\r?\n/ /gs;
+        return $class->temp_fail( $data, 'lj_friends', $job, 'Failure running job: %s', $msg );
     }
 }
 
 sub try_work {
-    my ( $class, $job ) = @_;
-    my $opts = $job->arg;
-    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
+    my ( $class, $job, $opts, $data ) = @_;
 
     # failure wrappers for convenience
     my $fail      = sub { return $class->fail( $data, 'lj_friends', $job, @_ ); };
diff -r 9bff62aa448e -r 31f6db459a34 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Tags.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Tags.pm	Tue Apr 21 05:47:37 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Tags.pm	Tue Apr 21 06:05:50 2009 +0000
@@ -24,18 +24,18 @@ use DW::Worker::ContentImporter::Local::
 
 sub work {
     my ( $class, $job ) = @_;
+    my $opts = $job->arg;
+    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
 
-    eval { try_work( $class, $job ); };
-    if ( $@ ) {
-        warn "Failure running job: $@\n";
-        return $class->temp_fail( $job, 'Failure running job: %s', $@ );
+    eval { try_work( $class, $job, $opts, $data ); };
+    if ( my $msg = $@ ) {
+        $msg =~ s/\r?\n/ /gs;
+        return $class->temp_fail( $data, 'lj_tags', $job, 'Failure running job: %s', $msg );
     }
 }
 
 sub try_work {
-    my ( $class, $job ) = @_;
-    my $opts = $job->arg;
-    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
+    my ( $class, $job, $opts, $data ) = @_;
 
     # failure wrappers for convenience
     my $fail      = sub { return $class->fail( $data, 'lj_tags', $job, @_ ); };
diff -r 9bff62aa448e -r 31f6db459a34 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Userpics.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Userpics.pm	Tue Apr 21 05:47:37 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Userpics.pm	Tue Apr 21 06:05:50 2009 +0000
@@ -29,18 +29,18 @@ use DW::Worker::ContentImporter::Local::
 
 sub work {
     my ( $class, $job ) = @_;
+    my $opts = $job->arg;
+    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
 
-    eval { try_work( $class, $job ); };
-    if ( $@ ) {
-        warn "Failure running job: $@\n";
-        return $class->temp_fail( $job, 'Failure running job: %s', $@ );
+    eval { try_work( $class, $job, $opts, $data ); };
+    if ( my $msg = $@ ) {
+        $msg =~ s/\r?\n/ /gs;
+        return $class->temp_fail( $data, 'lj_userpics', $job, 'Failure running job: %s', $msg );
     }
 }
 
 sub try_work {
-    my ( $class, $job ) = @_;
-    my $opts = $job->arg;
-    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
+    my ( $class, $job, $opts, $data ) = @_;
     my $begin_time = [ gettimeofday() ];
 
     # failure wrappers for convenience
diff -r 9bff62aa448e -r 31f6db459a34 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Verify.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Verify.pm	Tue Apr 21 05:47:37 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Verify.pm	Tue Apr 21 06:05:50 2009 +0000
@@ -24,18 +24,18 @@ use Carp qw/ croak confess /;
 
 sub work {
     my ( $class, $job ) = @_;
+    my $opts = $job->arg;
+    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
 
-    eval { try_work( $class, $job ); };
-    if ( $@ ) {
-        warn "Failure running job: $@\n";
-        return $class->temp_fail( $job, 'Failure running job: %s', $@ );
+    eval { try_work( $class, $job, $opts, $data ); };
+    if ( my $msg = $@ ) {
+        $msg =~ s/\r?\n/ /gs;
+        return $class->temp_fail( $data, 'lj_verify', $job, 'Failure running job: %s', $msg );
     }
 }
 
 sub try_work {
-    my ( $class, $job ) = @_;
-    my $opts = $job->arg;
-    my $data = $class->import_data( $opts->{userid}, $opts->{import_data_id} );
+    my ( $class, $job, $opts, $data ) = @_;
 
     # failure wrappers for convenience
     my $fail      = sub { return $class->fail( $data, 'lj_verify', $job, @_ ); };
--------------------------------------------------------------------------------