From fe9a8bf9735c7ea54d39aa1c19f667bf999a902d Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 13 Dec 2016 14:03:27 +0100 Subject: [PATCH] Bug 17669: Introduce new preference for purging temp uploads The new preference is: Upload_PurgeTemporaryFiles_Days. It controls if the cron job will delete temporary uploaded files and if so, how many days should have passed before doing so. Since the default value is empty, it will not start deleting these uploads until you change the pref. No behavior change. But the dbrev will print a message if you already have temporary uploads. Test plan: [1] Check Administration, Preferences, Tools for the new pref. [2] Run the db rev. If you have temporary uploads, check the reported count. [3] Bonus: Run sysprefs.sql in a safe environment. Signed-off-by: Marcel de Rooy Signed-off-by: Mirko Tietgen Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- installer/data/mysql/atomicupdate/bug17669.perl | 14 ++++++++++++++ installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/tools.pref | 6 ++++++ 3 files changed, 21 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug17669.perl diff --git a/installer/data/mysql/atomicupdate/bug17669.perl b/installer/data/mysql/atomicupdate/bug17669.perl new file mode 100644 index 0000000000..ef2e58f4b4 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug17669.perl @@ -0,0 +1,14 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do(q| +INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('Upload_PurgeTemporaryFiles_Days','',NULL,'If not empty, number of days used when automatically deleting temporary uploads','integer'); + |); + + my ( $cnt ) = $dbh->selectrow_array( "SELECT COUNT(*) FROM uploaded_files WHERE permanent IS NULL or permanent=0" ); + if( $cnt ) { + print "NOTE: You have $cnt temporary uploads. You could benefit from setting pref Upload_PurgeTemporaryFiles_Days now to automatically delete them.\n"; + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 17669 - Introduce preference for deleting temporary uploads)\n"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 64aa4930f0..a3f240ee39 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -540,6 +540,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('UniqueItemFields','barcode','','Space-separated list of fields that should be unique (used in acquisition module for item creation). Fields must be valid SQL column names of items table','Free'), ('UpdateNotForLoanStatusOnCheckin', '', 'NULL', 'This is a list of value pairs. When an item is checked in, if the not for loan value on the left matches the items not for loan value it will be updated to the right-hand value. E.g. ''-1: 0'' will cause an item that was set to ''Ordered'' to now be available for loan. Each pair of values should be on a separate line.', 'Free'), ('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'), +('Upload_PurgeTemporaryFiles_Days','',NULL,'If not empty, number of days used when automatically deleting temporary uploads','integer'), ('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'), ('URLLinkText','',NULL,'Text to display as the link anchor in the OPAC','free'), ('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref index a2a381d3f9..a64a25c42f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref @@ -26,3 +26,9 @@ Tools: staff: "Staff client only" both: "Both OPAC and staff client" - + Upload: + - + - Automatically delete temporary uploads older than + - pref: Upload_PurgeTemporaryFiles_Days + class: integer + - "days in cleanup_database cron job. NOTE: If you leave this field empty (zero), the cron job will not delete any files." -- 2.20.1