Better @INC fiddling and degenerate case for ProgressTree
This commit is contained in:
parent
f14545ec12
commit
bb8753cd2a
7 changed files with 49 additions and 23 deletions
|
|
@ -73,6 +73,7 @@ sub copyInFork {
|
||||||
}
|
}
|
||||||
my $ids = $asset->getLineage(\@pedigree);
|
my $ids = $asset->getLineage(\@pedigree);
|
||||||
my $tree = WebGUI::ProgressTree->new($session, $ids);
|
my $tree = WebGUI::ProgressTree->new($session, $ids);
|
||||||
|
$process->update(sub { $tree->json });
|
||||||
my $patch = Monkey::Patch::patch_class(
|
my $patch = Monkey::Patch::patch_class(
|
||||||
'WebGUI::Asset', 'duplicate', sub {
|
'WebGUI::Asset', 'duplicate', sub {
|
||||||
my $duplicate = shift;
|
my $duplicate = shift;
|
||||||
|
|
@ -331,6 +332,7 @@ sub pasteInFork {
|
||||||
} @roots;
|
} @roots;
|
||||||
|
|
||||||
my $tree = WebGUI::ProgressTree->new( $session, \@ids );
|
my $tree = WebGUI::ProgressTree->new( $session, \@ids );
|
||||||
|
$process->update(sub { $tree->json });
|
||||||
my $patch = Monkey::Patch::patch_class(
|
my $patch = Monkey::Patch::patch_class(
|
||||||
'WebGUI::Asset',
|
'WebGUI::Asset',
|
||||||
'indexContent',
|
'indexContent',
|
||||||
|
|
|
||||||
|
|
@ -664,6 +664,7 @@ sub exportInFork {
|
||||||
$args->{indexFileName} = delete $args->{index};
|
$args->{indexFileName} = delete $args->{index};
|
||||||
my $assetIds = $self->exportGetDescendants( undef, $args->{depth} );
|
my $assetIds = $self->exportGetDescendants( undef, $args->{depth} );
|
||||||
my $tree = WebGUI::ProgressTree->new( $session, $assetIds );
|
my $tree = WebGUI::ProgressTree->new( $session, $assetIds );
|
||||||
|
$process->update( sub { $tree->json } );
|
||||||
my %reports = (
|
my %reports = (
|
||||||
'done' => sub { $tree->success(shift) },
|
'done' => sub { $tree->success(shift) },
|
||||||
'exporting page' => sub { $tree->focus(shift) },
|
'exporting page' => sub { $tree->focus(shift) },
|
||||||
|
|
|
||||||
|
|
@ -225,6 +225,7 @@ sub purgeInFork {
|
||||||
} @roots;
|
} @roots;
|
||||||
|
|
||||||
my $tree = WebGUI::ProgressTree->new( $session, \@ids );
|
my $tree = WebGUI::ProgressTree->new( $session, \@ids );
|
||||||
|
$process->update( sub { $tree->json } );
|
||||||
my $patch = Monkey::Patch::patch_class(
|
my $patch = Monkey::Patch::patch_class(
|
||||||
'WebGUI::Asset',
|
'WebGUI::Asset',
|
||||||
'purge',
|
'purge',
|
||||||
|
|
@ -390,6 +391,7 @@ sub trashInFork {
|
||||||
} @roots;
|
} @roots;
|
||||||
|
|
||||||
my $tree = WebGUI::ProgressTree->new( $session, \@ids );
|
my $tree = WebGUI::ProgressTree->new( $session, \@ids );
|
||||||
|
$process->update(sub { $tree->json });
|
||||||
my $patch = Monkey::Patch::patch_class(
|
my $patch = Monkey::Patch::patch_class(
|
||||||
'WebGUI::Asset',
|
'WebGUI::Asset',
|
||||||
'setState',
|
'setState',
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,23 @@ sub canView {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 cleanINC(@INC)
|
||||||
|
|
||||||
|
Class method. Returns a new @INC array (but does not set it) to be used for
|
||||||
|
forked/daemonized processes. Note that you pass in @INC and new one is
|
||||||
|
returned, but doesn't replace the original. You must do that yourself.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub cleanINC {
|
||||||
|
# gotta get rid of hooks until we think of a way to serialize them in
|
||||||
|
# forkAndExec (if we ever want to). Serializing coderefs is a tricky
|
||||||
|
# business.
|
||||||
|
map { File::Spec->rel2abs($_) } grep { !ref } @_;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 contentPairs ($module, $pid, $extra)
|
=head2 contentPairs ($module, $pid, $extra)
|
||||||
|
|
||||||
Returns a bit of query string useful for redirecting to a
|
Returns a bit of query string useful for redirecting to a
|
||||||
|
|
@ -278,7 +295,7 @@ sub forkAndExec {
|
||||||
my $id = $self->getId;
|
my $id = $self->getId;
|
||||||
my $class = ref $self;
|
my $class = ref $self;
|
||||||
my $json = JSON::encode_json($request);
|
my $json = JSON::encode_json($request);
|
||||||
my @inc = map {"-I$_"} map { File::Spec->rel2abs($_) } grep { !ref } @INC;
|
my @inc = $class->cleanINC(@INC);
|
||||||
my @argv = (@inc, "-M$class", "-e$class->runCmd()" );
|
my @argv = (@inc, "-M$class", "-e$class->runCmd()" );
|
||||||
$class->daemonize(
|
$class->daemonize(
|
||||||
$json,
|
$json,
|
||||||
|
|
@ -413,6 +430,7 @@ sub init {
|
||||||
$0 = 'webgui-fork-master';
|
$0 = 'webgui-fork-master';
|
||||||
$pipe->reader;
|
$pipe->reader;
|
||||||
local $/ = "\x{0}";
|
local $/ = "\x{0}";
|
||||||
|
@INC = $class->cleanINC(@INC);
|
||||||
while ( my $request = $pipe->getline ) {
|
while ( my $request = $pipe->getline ) {
|
||||||
chomp $request;
|
chomp $request;
|
||||||
eval {
|
eval {
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ my $template = <<'TEMPLATE';
|
||||||
finished += 1;
|
finished += 1;
|
||||||
}
|
}
|
||||||
if (asset.focus) {
|
if (asset.focus) {
|
||||||
li.className += 'focus';
|
YAHOO.util.Dom.addClass(li, 'focus');
|
||||||
focus = asset.url;
|
focus = asset.url;
|
||||||
}
|
}
|
||||||
li.appendChild(document.createTextNode(txt));
|
li.appendChild(document.createTextNode(txt));
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,7 @@ sub rollbackInFork {
|
||||||
$update->();
|
$update->();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
$update->();
|
||||||
$tag->rollback( {
|
$tag->rollback( {
|
||||||
outputSub => sub {
|
outputSub => sub {
|
||||||
$status{message} = shift;
|
$status{message} = shift;
|
||||||
|
|
|
||||||
|
|
@ -46,30 +46,32 @@ Constructs new tree object for tracking the progress of $assetIds.
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, $session, $assetIds ) = @_;
|
my ( $class, $session, $assetIds ) = @_;
|
||||||
my $db = $session->db;
|
|
||||||
my $dbh = $db->dbh;
|
|
||||||
my $set = join( ',', map { $dbh->quote($_) } @$assetIds );
|
|
||||||
my $sql = qq{
|
|
||||||
SELECT a.assetId, a.parentId, d.url
|
|
||||||
FROM asset a INNER JOIN assetData d ON a.assetId = d.assetId
|
|
||||||
WHERE a.assetId IN ($set)
|
|
||||||
ORDER BY a.lineage ASC, d.revisionDate DESC
|
|
||||||
};
|
|
||||||
my $sth = $db->read($sql);
|
|
||||||
my ( %flat, @roots );
|
my ( %flat, @roots );
|
||||||
|
if (@$assetIds) {
|
||||||
|
my $db = $session->db;
|
||||||
|
my $dbh = $db->dbh;
|
||||||
|
my $set = join( ',', map { $dbh->quote($_) } @$assetIds );
|
||||||
|
my $sql = qq{
|
||||||
|
SELECT a.assetId, a.parentId, d.url
|
||||||
|
FROM asset a INNER JOIN assetData d ON a.assetId = d.assetId
|
||||||
|
WHERE a.assetId IN ($set)
|
||||||
|
ORDER BY a.lineage ASC, d.revisionDate DESC
|
||||||
|
};
|
||||||
|
my $sth = $db->read($sql);
|
||||||
|
|
||||||
while ( my $asset = $sth->hashRef ) {
|
while ( my $asset = $sth->hashRef ) {
|
||||||
my ( $id, $parentId ) = delete @{$asset}{ 'assetId', 'parentId' };
|
my ( $id, $parentId ) = delete @{$asset}{ 'assetId', 'parentId' };
|
||||||
|
|
||||||
# We'll get back multiple rows for each asset, but the first one is
|
# We'll get back multiple rows for each asset, but the first one
|
||||||
# the latest. Skip the others.
|
# is the latest. Skip the others.
|
||||||
next if $flat{$id};
|
next if $flat{$id};
|
||||||
$flat{$id} = $asset;
|
$flat{$id} = $asset;
|
||||||
if ( my $parent = $flat{$parentId} ) {
|
if ( my $parent = $flat{$parentId} ) {
|
||||||
push( @{ $parent->{children} }, $asset );
|
push( @{ $parent->{children} }, $asset );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
push( @roots, $asset );
|
push( @roots, $asset );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $self = {
|
my $self = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue