Changeset 32594 for main/trunk/greenstone2/perllib/gsmysql.pm
- Timestamp:
- 2018-11-09T21:23:48+13:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/gsmysql.pm
r32593 r32594 32 32 33 33 use DBI; # the central package for this module used by GreenstoneSQL Plugout and Plugin 34 use FileUtils; 35 use gsprintf; 34 36 35 37 ################# … … 110 112 print STDERR " User cancelled: rolling back SQL database transaction.\n"; 111 113 $_dbh_instance->rollback(); # will warn on failure, nothing more we can/want to do, 114 115 print STDERR "****************************\n"; 116 &gsprintf::gsprintf(STDERR, "{gsmysql.restore_backups_on_build_cancel_msg}\n"); 117 print STDERR "****************************\n"; 112 118 } 113 119 } … … 219 225 { 220 226 my $self= shift (@_); 221 my ($params_map) = @_; 227 my ($params_map) = @_; # map instead of named vars with an eye on gssql inheritance 222 228 223 229 $params_map->{'db_encoding'} = $self->{'db_encoding'}; … … 237 243 { 238 244 #my $self= shift (@_); # singleton method doesn't use self, but callers don't need to know that 239 my ($params_map) = @_; 240 241 if($params_map->{'verbosity'}) { 242 if(!defined $params_map->{'autocommit'}) { 243 print STDERR " Autocommit parameter not defined\n"; 244 } 245 if($params_map->{'autocommit'}) { 246 print STDERR " SQL DB CANCEL SUPPORT OFF.\n" if($params_map->{'verbosity'} > 2); 247 } else { 248 print STDERR " SQL DB CANCEL SUPPORT ON.\n"; 249 } 250 } 245 my ($params_map) = @_; 246 251 247 252 248 return $_dbh_instance if($_dbh_instance); 253 254 249 # or make the connection 250 251 252 # some useful user messages first 253 if(!defined $params_map->{'autocommit'} && $params_map->{'verbosity'}) { 254 print STDERR " Autocommit parameter not defined\n"; 255 } 256 if($params_map->{'autocommit'}) { 257 print STDERR " SQL DB CANCEL SUPPORT OFF.\n" if($params_map->{'verbosity'} > 2); 258 } else { # rollback on cancel support on 259 &issue_backup_on_build_message(); 260 } 261 255 262 256 263 # For proper utf8 support in MySQL, encoding should be 'utf8mb4' as 'utf8' is insufficient … … 779 786 } 780 787 788 # regular function, not method 789 # Called when rollback_on_cancel is on. 790 # Warns they user to make backups of their archives and index dir 791 # and sleeps for 5 seconds so they can do that 792 sub issue_backup_on_build_message 793 { 794 # warn the user they'll need to backup their archives (and index?) folders 795 # plugout stores archivedir in $self->{'output_dir'}, but not available in plugin 796 # But we're only making an example copy command anyway: 797 my $archivesdir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "archives"); 798 my $archives_rollbackdir = $archivesdir.".rollback"; 799 800 # Assume user knows what they're doing if a rollback directory already exists 801 # instead of wasting time waiting for sleep to terminate 802 return if FileUtils::directoryExists("$archives_rollbackdir"); 803 804 my $indexdir = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "index"); 805 806 807 # use rsync command on unix 808 my $example_copy_cmds = "rsync -pavH $archivesdir $archivesdir.rollback\n"; 809 $example_copy_cmds .= "rsync -pavH $indexdir $indexdir.rollback\n"; 810 811 if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 812 # https://stackoverflow.com/questions/4601161/copying-all-contents-of-folder-to-another-folder-using-batch-file 813 $example_copy_cmds = "xcopy /EVI $archivesdir $archivesdir.rollback\n"; 814 $example_copy_cmds .= "xcopy /EVI $indexdir $indexdir.rollback\n"; 815 816 } 817 print STDERR "****************************\n"; 818 &gsprintf::gsprintf(STDERR, "{gsmysql.backup_on_build_msg}\n", $example_copy_cmds); 819 print STDERR "****************************\n"; 820 sleep 5; # 5s 821 } 822 781 823 1;
Note:
See TracChangeset
for help on using the changeset viewer.