Two command line options are added:
[1] -temp-uploads to indicate that you want to purge these uploads,
[2] -temp-uploads-override DAYS to (optionally) tell that you want to
override the corresponding pref value.
Test plan:
[1] Check the modified usage statement.
[2] If needed, backup your temporary uploads :)
In case you do not have one, add a temporary one with Tools/Upload.
Note: Do not choose an upload category.
[3] Set pref to 0, and run cleanup_database with only --temp-uploads.
No files should be deleted.
[4] Check number of "old" temp uploads. Set pref to nonzero value.
Verify that the oldest are gone (depending on the value chosen).
[5] Set pref to 0 again.
If all uploads are gone now, add a new one with Tools/Upload.
Run cleanup_database with --temp-uploads --temp-uploads-override -1
All temporary files are gone.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
use Getopt::Long;
use C4::Log;
use C4::Accounts;
use Getopt::Long;
use C4::Log;
use C4::Accounts;
+use Koha::UploadedFiles;
sub usage {
print STDERR <<USAGE;
sub usage {
print STDERR <<USAGE;
-Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS]
+Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] [--temp-uploads] [--temp-uploads-override DAYS]
-h --help prints this help message, and exits, ignoring all
other options
-h --help prints this help message, and exits, ignoring all
other options
--del-exp-selfreg Delete expired self registration accounts
--del-unv-selfreg DAYS Delete unverified self registrations older than DAYS
--unique-holidays DAYS Delete all unique holidays older than DAYS
--del-exp-selfreg Delete expired self registration accounts
--del-unv-selfreg DAYS Delete unverified self registrations older than DAYS
--unique-holidays DAYS Delete all unique holidays older than DAYS
+ --temp-uploads Delete temporary uploads.
+ --temp-uploads-override DAYS Override the corresponding preference value.
my $pUnvSelfReg;
my $fees_days;
my $special_holidays_days;
my $pUnvSelfReg;
my $fees_days;
my $special_holidays_days;
+my $temp_uploads;
+my $override_temp_uploads;
GetOptions(
'h|help' => \$help,
GetOptions(
'h|help' => \$help,
'del-exp-selfreg' => \$pExpSelfReg,
'del-unv-selfreg' => \$pUnvSelfReg,
'unique-holidays:i' => \$special_holidays_days,
'del-exp-selfreg' => \$pExpSelfReg,
'del-unv-selfreg' => \$pUnvSelfReg,
'unique-holidays:i' => \$special_holidays_days,
+ 'temp-uploads' => \$temp_uploads,
+ 'temp-uploads-override:i' => \$override_temp_uploads,
) || usage(1);
# Use default values
) || usage(1);
# Use default values
|| $pExpSelfReg
|| $pUnvSelfReg
|| $special_holidays_days
|| $pExpSelfReg
|| $pUnvSelfReg
|| $special_holidays_days
) {
print "You did not specify any cleanup work for the script to do.\n\n";
usage(1);
) {
print "You did not specify any cleanup work for the script to do.\n\n";
usage(1);
DeleteSpecialHolidays( abs($special_holidays_days) );
}
DeleteSpecialHolidays( abs($special_holidays_days) );
}
+if( $temp_uploads ) {
+ # Delete temporary uploads, governed by a pref.
+ # If the pref is empty, nothing happens (unless you override).
+ print "Purging temporary uploads.\n" if $verbose;
+ Koha::UploadedFiles->delete_temporary({
+ override_pref => $override_temp_uploads,
+ });
+ print "Done purging temporary uploads.\n" if $verbose;
+}
+
exit(0);
sub RemoveOldSessions {
exit(0);
sub RemoveOldSessions {