}
else {
# catch all defaults to tmp should work on all systems
- my $dir = Koha::UploadedFile->temporary_directory;
+ my $dir = C4::Context::temporary_directory;
my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is
return { dsn => "driver:File;serializer:yaml;id:md5", dsn_args => { Directory => "$dir/cgisess_$instance" } };
}
&& C4::Context->userenv->{branch};
}
+=head3 temporary_directory
+
+Returns root directory for temporary storage
+
+=cut
+
+sub temporary_directory {
+ my ( $class ) = @_;
+ return C4::Context->config('tmp_path') || File::Spec->tmpdir;
+}
+
+
1;
__END__
my $dbh = C4::Context->dbh();
my $template_name;
$template_name = "installer/auth.tt";
- my $sessdir = File::Spec->catdir( Koha::UploadedFile->temporary_directory, 'cgisess_' . C4::Context->config('database') ); # same construction as in C4/Auth
+ my $sessdir = File::Spec->catdir( C4::Context::temporary_directory, 'cgisess_' . C4::Context->config('database') ); # same construction as in C4/Auth
# state variables
my $loggedin = 0;
my $self = {
account => $acct,
schema => $schema,
- working_dir => Koha::UploadedFile->temporary_directory, #temporary work directory
+ working_dir => C4::Context::temporary_directory, #temporary work directory
transfer_date => DateTime->now( time_zone => 'local' ),
};
return C4::Context->config('upload_path');
}
-=head3 tmp_directory
-
-Returns root directory for temporary storage
-
-=cut
-
-sub temporary_directory {
- my ( $class ) = @_;
- return C4::Context->config('tmp_path') || File::Spec->tmpdir;
-}
-
=head3 _type
Returns name of corresponding DBIC resultset
my ( $self, $params ) = @_;
$self->{rootdir} = Koha::UploadedFile->permanent_directory;
- $self->{tmpdir} = Koha::UploadedFile->temporary_directory;
+ $self->{tmpdir} = C4::Context::temporary_directory;
$params->{tmp} = $params->{temp} if !exists $params->{tmp};
$self->{temporary} = $params->{tmp}? 1: 0; #default false
}
if ( ! C4::Context->config('tmp_path') ) {
- my $temporary_directory = Koha::UploadedFile->temporary_directory;
+ my $temporary_directory = C4::Context::temporary_directory;
push @xml_config_warnings, {
error => 'tmp_path_missing',
effective_tmp_dir => $temporary_directory,
sub get_filename {
my $directory = shift;
if ( !$directory ) {
- $directory = Koha::UploadedFile->temporary_directory;
+ $directory = C4::Context::temporary_directory;
}
if ( !-d $directory ) {
carp "Could not write to $directory ... does not exist!";
# test absolute path change in get_template with Koha::Plugin::Test
# using the mock set before
# we also add tmpdir as an approved template dir
-t::lib::Mocks::mock_config( 'pluginsdir', [ Koha::UploadedFile->temporary_directory ] );
+t::lib::Mocks::mock_config( 'pluginsdir', [ C4::Context::temporary_directory ] );
my ( $fh, $fn ) = tempfile( SUFFIX => '.tt', UNLINK => 1 );
print $fh 'I am [% filename %]';
close $fh;
_new_schema => sub { return Schema(); }
);
-my $dir = Koha::UploadedFile->temporary_directory;
+my $dir = C4::Context::temporary_directory;
my $data = [
[qw/ 1 2013-11-15 2013-11-15/],
# We create a simple template in /tmp.
# We simulate an anonymous OPAC session; the OPACBaseURL template variable
# should be filled by get_template_and_user.
- t::lib::Mocks::mock_config( 'pluginsdir', [ Koha::UploadedFile->temporary_directory ] );
+ t::lib::Mocks::mock_config( 'pluginsdir', [ C4::Context::temporary_directory ] );
t::lib::Mocks::mock_preference( 'OPACBaseURL', 'without any doubt' );
- my ( $fh, $fn ) = tempfile( SUFFIX => '.tt', UNLINK => 1, DIR => Koha::UploadedFile->temporary_directory );
+ my ( $fh, $fn ) = tempfile( SUFFIX => '.tt', UNLINK => 1, DIR => C4::Context::temporary_directory );
print $fh q|I am a [% quality %] template [% OPACBaseURL %]|;
close $fh;
my ( $template, $login, $cookie ) = C4::Auth::get_template_and_user({
# Check mocked directories
is( Koha::UploadedFile->permanent_directory, $tempdir,
'Check permanent directory' );
- is( Koha::UploadedFile->temporary_directory, $tempdir,
+ is( C4::Context::temporary_directory, $tempdir,
'Check temporary directory' );
};