Bugzilla – Attachment 87430 Details for
Bug 22508
Add the ability to prefill 856$u with the direct URL of the file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22508: Delete the public file on deleting the upload
Bug-22508-Delete-the-public-file-on-deleting-the-u.patch (text/plain), 2.90 KB, created by
Jonathan Druart
on 2019-04-05 01:07:53 UTC
(
hide
)
Description:
Bug 22508: Delete the public file on deleting the upload
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-04-05 01:07:53 UTC
Size:
2.90 KB
patch
obsolete
>From 7be5e8a5d1e2a8abaa3ce08846d43627c64438c6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 4 Apr 2019 11:53:22 -0300 >Subject: [PATCH] Bug 22508: Delete the public file on deleting the upload > >--- > Koha/UploadedFile.pm | 6 ++++++ > t/db_dependent/Upload.t | 16 +++++++++++++++- > 2 files changed, 21 insertions(+), 1 deletion(-) > >diff --git a/Koha/UploadedFile.pm b/Koha/UploadedFile.pm >index 982cdc6ae3..990c7ebfc8 100644 >--- a/Koha/UploadedFile.pm >+++ b/Koha/UploadedFile.pm >@@ -73,6 +73,7 @@ sub delete { > > my $name = $self->filename; > my $file = $self->full_path; >+ my $public_filepath = $self->local_public_path; > > my $retval = $self->SUPER::delete; > if( !defined($retval) ) { # undef is Unknown (-1) >@@ -90,6 +91,11 @@ sub delete { > } elsif( ! unlink($file) ) { > warn "Problem while deleting: $file"; > } >+ >+ if( -e $public_filepath and ! unlink($public_filepath) ) { >+ warn "Problem while deleting: $public_filepath"; >+ } >+ > return $retval; > } > >diff --git a/t/db_dependent/Upload.t b/t/db_dependent/Upload.t >index 162b5dfb32..9b68f6d813 100644 >--- a/t/db_dependent/Upload.t >+++ b/t/db_dependent/Upload.t >@@ -51,6 +51,10 @@ our $uploads = [ > # Redirect upload dir structure and mock C4::Context and CGI > my $tempdir = tempdir( CLEANUP => 1 ); > t::lib::Mocks::mock_config('upload_path', $tempdir); >+ my $publictempdir = tempdir( CLEANUP => 1 ); >+ my $public_base_url = 'http://my_opac/public_dir'; >+ t::lib::Mocks::mock_config('upload_public_path', $publictempdir); >+ t::lib::Mocks::mock_config('upload_public_url', $public_base_url); > my $specmod = Test::MockModule->new( 'C4::Context' ); > $specmod->mock( 'temporary_directory' => sub { return $tempdir; } ); > my $cgimod = Test::MockModule->new( 'CGI' ); >@@ -149,7 +153,7 @@ subtest 'Add same file in same category' => sub { > }; > > subtest 'Test delete via UploadedFile as well as UploadedFiles' => sub { >- plan tests => 12; >+ plan tests => 14; > > # add temporary file with same name and contents (file4) > my $upl = Koha::Uploader->new({ tmp => 1 }); >@@ -193,6 +197,16 @@ subtest 'Test delete via UploadedFile as well as UploadedFiles' => sub { > ok( $delete =~ /^(0E0|-1)$/, 'Repeated delete unsuccessful' ); > is( -e $path, 1, 'File exists if keep_file is passed on deleting' ); > # NOTE: Koha::Object->delete does not return 0E0 (yet?) >+ >+ # testing delete direct public path >+ $upl = Koha::Uploader->new({ tmp => 1 }); >+ $upl->cgi; >+ $kohaobj = Koha::UploadedFiles->find( $upl->result ); >+ my $local_public_path = $kohaobj->local_public_path; >+ is( -e $local_public_path, 1, 'Local public file exist after create' ); >+ $delete = $kohaobj->delete; >+ ok( $delete=~/^-?1$/, 'Delete successful' ); >+ isnt( -e $local_public_path, 1, 'Local public file no longer found after delete' ); > }; > > subtest 'Test delete_missing' => sub { >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22508
:
86583
|
86584
|
86585
|
87272
|
87273
|
87274
|
87430
|
87431
|
87432
|
89540
|
89541
|
89542
|
89543
|
89544
|
89545
|
89617