Commit 063e9681 authored by Leigh Stoller's avatar Leigh Stoller

Minor fix for where the archive library finds files to archive in the

experiment underlying a template. Rather then using the experiment directory
we use the template directory in /proj/$pid/templates ...
parent f3d49948
......@@ -131,7 +131,9 @@ sub Lookup($$;$)
if (exists($experiments{"$idx"}));
my $query_result =
DBQueryWarn("select e.*,i.parent_guid from experiments as e ".
DBQueryWarn("select e.*,i.parent_guid,t.guid from experiments as e ".
"left join experiment_templates as t on ".
" t.exptidx=e.idx ".
"left join experiment_template_instances as i on ".
" i.exptidx=e.idx ".
"where e.idx='$idx'");
......@@ -143,6 +145,8 @@ sub Lookup($$;$)
$self->{'EXPT'} = $query_result->fetchrow_hashref();
# An Instance?
$self->{'ISINSTANCE'} = defined($self->{'EXPT'}->{'parent_guid'});
# The experiment underlying a template.
$self->{'ISTEMPLATE'} = defined($self->{'EXPT'}->{'guid'});
$query_result =
DBQueryWarn("select * from experiment_stats where exptidx='$idx'");
......@@ -577,7 +581,6 @@ sub Refresh($)
if (!$query_result || !$query_result->numrows);
$self->{'EXPT'} = $query_result->fetchrow_hashref();
$self->{'ISINSTANCE'} = undef;
$query_result =
DBQueryWarn("select * from experiment_stats where exptidx='$idx'");
......@@ -2413,20 +2416,21 @@ sub IsInstance($)
return 0
if (! ref($self));
if (defined($self->{'ISINSTANCE'})) {
return $self->{'ISINSTANCE'};
}
my $idx = $self->idx();
return $self->{'ISINSTANCE'};
}
my $query_result =
DBQueryWarn("select parent_guid from experiment_template_instances ".
"where exptidx='$idx'");
#
# Is this experiment the one underlying a template.
#
sub IsTemplate($)
{
my ($self) = @_;
# Must be a real reference.
return 0
if (!$query_result);
if (! ref($self));
$self->{'ISINSTANCE'} = $query_result->numrows;
return $self->{'ISINSTANCE'};
return $self->{'ISTEMPLATE'};
}
#
......
......@@ -23,6 +23,7 @@ use Project;
use English;
use Experiment;
use Archive;
use Template;
use File::stat;
use File::Basename;
use POSIX qw(strftime);
......@@ -183,6 +184,10 @@ sub TBExperimentArchiveAddUserFiles($$)
return 0
if (!Archive::doarchiving($pid, $eid));
my $experiment = Experiment->Lookup($pid, $eid);
return -1
if (!defined($experiment));
my $rval = TBExperimentArchive($pid, $eid, \$archive, \$view);
return 0
......@@ -190,7 +195,17 @@ sub TBExperimentArchiveAddUserFiles($$)
return -1
if ($rval < 0);
my $userdir = TBExptUserDir($pid, $eid);
my $userdir;
if ($experiment->IsTemplate()) {
# XXX Fix this
my $template = Template->LookupByPidEid($pid, $eid);
$userdir = $template->path();
}
else {
$userdir = $experiment->UserDir();
}
if (-e $userdir) {
$rval = $archive->Add("$userdir/.", $view, 1, 1);
......@@ -212,13 +227,27 @@ sub TBExperimentArchiveDiffUserFiles($$)
return 0
if (!Archive::doarchiving($pid, $eid));
my $experiment = Experiment->Lookup($pid, $eid);
return -1
if (!defined($experiment));
my $rval = TBExperimentArchive($pid, $eid, \$archive, \$view);
return 0
if ($rval > 0);
return -1
if ($rval < 0);
my $userdir = TBExptUserDir($pid, $eid);
my $userdir;
if ($experiment->IsTemplate()) {
# XXX Fix this
my $template = Template->LookupByPidEid($pid, $eid);
$userdir = $template->path();
}
else {
$userdir = $experiment->UserDir();
}
if (-e $userdir) {
$rval = $archive->Diff("$userdir/.", $view);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment