Create export dir and commit after session.
This commit is contained in:
parent
d7446596d9
commit
6514b6cdb6
|
@ -239,6 +239,7 @@ sub release_fileset {
|
|||
|
||||
$self->log(3, "releasing fileset $target->{id}");
|
||||
$self->{dbh}->do(q{update filesets set pid=null where id=? and pid=?}, {}, $target->{id}, $$);
|
||||
$self->{dbh}->commit();
|
||||
}
|
||||
|
||||
|
||||
|
@ -569,6 +570,7 @@ sub new_session {
|
|||
sub close_session {
|
||||
my ($self) = @_;
|
||||
$self->{dbh}->do("update sessions set end_date=? where id=?", {}, time(), $self->{session_id});
|
||||
$self->{dbh}->commit();
|
||||
$self->close_file_connection;
|
||||
delete $self->{target};
|
||||
}
|
||||
|
@ -827,6 +829,7 @@ sub export {
|
|||
my ($self) = @_;
|
||||
my $dbh = $self->{dbh};
|
||||
my $exportdir = $self->basedir . "/export";
|
||||
mkdir($exportdir);
|
||||
|
||||
my $sessions = $dbh->selectcol_arrayref("select id from sessions order by id");
|
||||
for my $session_id (@$sessions) {
|
||||
|
@ -848,14 +851,14 @@ sub export {
|
|||
and files.fileset=filesets.id
|
||||
});
|
||||
$sth->execute;
|
||||
open my $fh, '>', "$exportdir/$session_id.tsv.$$";
|
||||
open my $fh, '>', "$exportdir/$session_id.tsv.$$" or die "cannot create $exportdir/$session_id.tsv.$$: $!";
|
||||
print $fh join("\t", @{$sth->{NAME}}), "\n";
|
||||
while (my $r = $sth->fetchrow_arrayref) {
|
||||
no warnings 'uninitialized';
|
||||
print $fh join("\t", @$r), "\n";
|
||||
print $fh join("\t", @$r), "\n" or die "cannot write to $exportdir/$session_id.tsv.$$: $!";
|
||||
}
|
||||
close($fh);
|
||||
rename "$exportdir/$session_id.tsv.$$", "$exportdir/$session_id.tsv";
|
||||
rename "$exportdir/$session_id.tsv.$$", "$exportdir/$session_id.tsv" or die "cannot rename $exportdir/$session_id.tsv.$$ to $exportdir/$session_id.tsv: $!";
|
||||
system "/bin/gzip", "$exportdir/$session_id.tsv";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue