[dw-free] Allow importing of your journal from another LiveJournal-based site.
[commit: http://hg.dwscoalition.org/dw-free/rev/ab4d2d069b02]
http://bugs.dwscoalition.org/show_bug.cgi?id=114
Temp importer frontend should only show the most recent import. Also,
cancel existing imports when a new one is scheduled. This used the new enum
'aborted'. This should reduce confusion until we get a new importer
frontend put together to better explain things.
Patch by
mark.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=114
Temp importer frontend should only show the most recent import. Also,
cancel existing imports when a new one is scheduled. This used the new enum
'aborted'. This should reduce confusion until we get a new importer
frontend put together to better explain things.
Patch by
![[staff profile]](https://www.dreamwidth.org/img/silk/identity/user_staff.png)
Files modified:
- bin/upgrading/update-db-general.pl
- htdocs/misc/import.bml
-------------------------------------------------------------------------------- diff -r fa9ef6b6564d -r ab4d2d069b02 bin/upgrading/update-db-general.pl --- a/bin/upgrading/update-db-general.pl Mon Apr 13 06:49:39 2009 +0000 +++ b/bin/upgrading/update-db-general.pl Mon Apr 13 07:03:33 2009 +0000 @@ -3106,7 +3106,7 @@ CREATE TABLE import_items ( CREATE TABLE import_items ( userid INT UNSIGNED NOT NULL, item VARCHAR(255) NOT NULL, - status ENUM('init', 'ready', 'queued', 'failed', 'succeeded') NOT NULL DEFAULT 'init', + status ENUM('init', 'ready', 'queued', 'failed', 'succeeded', 'aborted') NOT NULL DEFAULT 'init', created INT UNSIGNED NOT NULL, last_touch INT UNSIGNED NOT NULL, import_data_id INT UNSIGNED NOT NULL, @@ -3974,6 +3974,13 @@ register_alter(sub { "ALTER TABLE ml_items ADD COLUMN visible TINYINT NOT NULL DEFAULT 0 AFTER updated" ); } + unless ( column_type( 'import_items', 'status' ) =~ /aborted/ ) { + do_alter( 'import_items', + q{ALTER TABLE import_items MODIFY COLUMN + status ENUM('init', 'ready', 'queued', 'failed', 'succeeded', 'aborted') + NOT NULL DEFAULT 'init'} ); + } + }); diff -r fa9ef6b6564d -r ab4d2d069b02 htdocs/misc/import.bml --- a/htdocs/misc/import.bml Mon Apr 13 06:49:39 2009 +0000 +++ b/htdocs/misc/import.bml Mon Apr 13 07:03:33 2009 +0000 @@ -59,6 +59,15 @@ body<= ); return "Database error." if $dbh->err; + # this is a hack, but we use it until we get a better frontend. we abort all + # existing import jobs if they schedule a new one. this won't actually stop any + # TheSchwartz jobs thateare in progress, of course, but that should be okay + $dbh->do( + q{UPDATE import_items SET status = 'aborted' + WHERE userid = ? AND status IN ('init', 'ready', 'queued')}, + undef, $u->id + ); + # if comments are on, turn entries on $POST{lj_entries} = 1 if $POST{lj_comments}; @@ -96,12 +105,12 @@ body<= return BML::redirect( "$LJ::SITEROOT/misc/import.bml" ); } - # load up their most recent ten imports + # load up their most recent (active) import my $dbh = LJ::get_db_writer() or return "No database."; my $imps = $dbh->selectall_arrayref( 'SELECT import_data_id, hostname, username, password_md5 FROM import_data WHERE userid = ? ' . - 'ORDER BY import_data_id DESC LIMIT 3', + 'ORDER BY import_data_id DESC LIMIT 1', undef, $u->id ); --------------------------------------------------------------------------------