* $HYDRA_DATA environment variable.
This commit is contained in:
@ -2,6 +2,7 @@ package Hydra;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Hydra::Helper::Nix;
|
||||
|
||||
use Catalyst::Runtime '5.70';
|
||||
|
||||
@ -20,8 +21,11 @@ our $VERSION = '0.01';
|
||||
|
||||
__PACKAGE__->config(
|
||||
name => 'Hydra',
|
||||
default_view => "TT"
|
||||
);
|
||||
default_view => "TT",
|
||||
session => {
|
||||
storage => getHydraPath . "/session_data"
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->setup();
|
||||
|
||||
|
@ -751,7 +751,7 @@ sub closure :Local {
|
||||
|
||||
return error($c, "Product is not a Nix build.") if $product->type ne "nix-build";
|
||||
|
||||
return error($c, "Path " . $product->path . " is no longer available.") unless Hydra::Helper::Nix::isValidPath($product->path);
|
||||
return error($c, "Path " . $product->path . " is no longer available.") unless isValidPath($product->path);
|
||||
|
||||
$c->stash->{current_view} = 'Hydra::View::NixClosure';
|
||||
$c->stash->{storePath} = $product->path;
|
||||
|
@ -1,14 +1,39 @@
|
||||
package Hydra::Helper::Nix;
|
||||
|
||||
use strict;
|
||||
use Exporter;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(isValidPath getHydraPath getHydraDBPath openHydraDB);
|
||||
|
||||
|
||||
sub isValidPath {
|
||||
my $path = shift;
|
||||
$SIG{CHLD} = 'DEFAULT'; # !!! work around system() failing if SIGCHLD is ignored
|
||||
return system("nix-store --check-validity $path") == 0;
|
||||
return system("nix-store --check-validity $path 2> /dev/null") == 0;
|
||||
}
|
||||
|
||||
|
||||
sub getHydraPath {
|
||||
my $dir = $ENV{HYDRA_DATA};
|
||||
die "The HYDRA_DATA environment variable is not set!\n" unless defined $dir;
|
||||
die "The HYDRA_DATA directory does not exist!\n" unless -d $dir;
|
||||
return $dir;
|
||||
}
|
||||
|
||||
|
||||
sub getHydraDBPath {
|
||||
my $path = getHydraPath . '/hydra.sqlite';
|
||||
die "The Hydra database ($path) not exist!\n" unless -f $path;
|
||||
return "dbi:SQLite:$path";
|
||||
}
|
||||
|
||||
|
||||
sub openHydraDB {
|
||||
my $db = Hydra::Schema->connect(getHydraDBPath, "", "", {});
|
||||
$db->storage->dbh->do("PRAGMA synchronous = OFF;");
|
||||
return $db;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
@ -2,13 +2,11 @@ package Hydra::Model::DB;
|
||||
|
||||
use strict;
|
||||
use base 'Catalyst::Model::DBIC::Schema';
|
||||
use Hydra::Helper::Nix;
|
||||
|
||||
__PACKAGE__->config(
|
||||
schema_class => 'Hydra::Schema',
|
||||
connect_info => [
|
||||
'dbi:SQLite:../hydra.sqlite',
|
||||
|
||||
],
|
||||
connect_info => [getHydraDBPath],
|
||||
);
|
||||
|
||||
=head1 NAME
|
||||
|
Reference in New Issue
Block a user