Ignore:
Timestamp:
2010-02-04T13:04:56+13:00 (14 years ago)
Author:
mdewsnip
Message:

Adding some comments and error checking. By Jeffrey Ke.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/cgiactions/baseaction.pm

    r21564 r21715  
    370370
    371371
     372# Release the gli.lck otherwise no one else will be able to use the collection again.
     373sub unlock_collection
     374{
     375    my $self = shift @_;
     376    my ($username, $collection) = @_;
     377    my $gsdl_cgi = $self->{'gsdl_cgi'};
     378
     379    # Obtain the path to the collection GLI lock file
     380    my $lock_file_path = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection, "gli.lck");
     381
     382    # If the lock file does exist, check if it is ours
     383    if (-e $lock_file_path)
     384    {
     385    my $lock_file_content = "";
     386    open(LOCK_FILE, "<$lock_file_path");
     387    while (<LOCK_FILE>) {
     388        $lock_file_content .= $_;
     389    }
     390    close(LOCK_FILE);
     391
     392    # Pick out the owner of the lock file
     393    $lock_file_content =~ /\<User\>(.*?)\<\/User\>/;
     394    my $lock_file_owner = $1;
     395
     396    # If we are the owner of this lock, we have the right to delete it
     397    if ($lock_file_owner eq $username) {
     398            unlink($lock_file_path );
     399    }
     400        else {
     401        $gsdl_cgi->generate_error("Collection is locked by: $lock_file_owner. Cannot be unlocked");
     402        }
     403    }
     404}
     405
     406
    372407sub send_mail
    373408{
Note: See TracChangeset for help on using the changeset viewer.