From cd639d72ba42aa0aa966729d41be24eb050aa0fc Mon Sep 17 00:00:00 2001 From: pcanterino <> Date: Thu, 10 Feb 2005 18:42:10 +0000 Subject: [PATCH] - Check if unlocking of the list of files in use was successful - Check if a file could be successfully added to the list of files in use - Check if a file could be successfully removed from the list of files in use --- devedit.pl | 12 ++++++++---- errors.dat | 3 +++ modules/Command.pm | 16 +++++++++------- modules/File/Access.pm | 10 +++++----- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/devedit.pl b/devedit.pl index 22dc403..b63d3a1 100644 --- a/devedit.pl +++ b/devedit.pl @@ -6,7 +6,7 @@ # Dev-Editor's main program # # Author: Patrick Canterino -# Last modified: 2005-01-06 +# Last modified: 2005-02-10 # use strict; @@ -122,10 +122,14 @@ if(-e clean_path($config->{'fileroot'}.'/'.$file)) version => $VERSION, configfile => CONFIGFILE); - my $output = exec_command($command,\%data,$config); # Execute the command... + # Execute the command... - $uselist->unlock; # ... unlock the list with files in use... - print $$output; # ... and show the output of the command + my $output = exec_command($command,\%data,$config); + + # ... unlock the list with files in use and show the output of the command + + $uselist->unlock or abort($config->{'errors'}->{'unlock_failed'},undef,{USELIST => $uselist->{'listfile'}, LOCK_FILE => $uselist->{'lockfile'}}); + print $$output; } else { diff --git a/errors.dat b/errors.dat index 88be554..8ead289 100644 --- a/errors.dat +++ b/errors.dat @@ -40,5 +40,8 @@ remove_root = You are not allowed to remove the root directory. rename_failed = Could not move/rename '{FILE}' to '{NEW_FILE}'. rename_root = You are not allowed to move/rename the root directory. text_to_binary = You are not allowed to write text data into a binary file. +ul_add_failed = Could not add '{FILE}' to the list of files in use. +ul_rm_failed = Could not remove '{FILE}' from the list of files in use. Try it again using the 'unlock' command of Dev-Editor or by removing the file manually from '{USELIST}'. +unlock_failed = Unlocking of '{USELIST}' failed. Ask the administrator to check the lock file ('{LOCK_FILE}') and to recreate it if necessary. # End of configuration file \ No newline at end of file diff --git a/modules/Command.pm b/modules/Command.pm index 8ffc765..adb62a7 100644 --- a/modules/Command.pm +++ b/modules/Command.pm @@ -6,7 +6,7 @@ package Command; # Execute Dev-Editor's commands # # Author: Patrick Canterino -# Last modified: 2005-01-24 +# Last modified: 2005-02-10 # use strict; @@ -279,8 +279,8 @@ sub exec_beginedit($$) # Lock the file... - $uselist->add_file($virtual); - $uselist->save; + ($uselist->add_file($virtual) and + $uselist->save) or return error($config->{'errors'}->{'ul_add_failed'},$dir,{FILE => $virtual}); # ... and show the editing form @@ -315,9 +315,11 @@ sub exec_canceledit($$) { my ($data,$config) = @_; my $virtual = $data->{'virtual'}; + my $dir = upper_path($virtual); + my $uselist = $data->{'uselist'}; - file_unlock($data->{'uselist'},$virtual); - return devedit_reload({command => 'show', file => upper_path($virtual)}); + file_unlock($uselist,$virtual) or return error($config->{'errors'}->{'ul_rm_failed'},$dir,{FILE => $virtual, USELIST => $uselist->{'listfile'}}); + return devedit_reload({command => 'show', file => $dir}); } # exec_endedit() @@ -343,7 +345,7 @@ sub exec_endedit($$) # No other user of Dev-Editor will access the file during this # routine because of the concept of File::UseList. - file_unlock($uselist,$virtual); + file_unlock($uselist,$virtual) or return error($config->{'errors'}->{'ul_rm_failed'},$dir,{FILE => $virtual, USELIST => $uselist->{'listfile'}}); # Normalize newlines @@ -855,7 +857,7 @@ sub exec_unlock($$) if($data->{'cgi'}->param('confirmed')) { - file_unlock($uselist,$virtual); + file_unlock($uselist,$virtual) or return error($config->{'errors'}->{'ul_rm_failed'},$dir,{FILE => $virtual, USELIST => $uselist->{'listfile'}}); return devedit_reload({command => 'show', file => $dir}); } else diff --git a/modules/File/Access.pm b/modules/File/Access.pm index d892ed8..4c4d0da 100644 --- a/modules/File/Access.pm +++ b/modules/File/Access.pm @@ -7,7 +7,7 @@ package File::Access; # using only one command # # Author: Patrick Canterino -# Last modified: 2005-02-09 +# Last modified: 2005-02-10 # use strict; @@ -192,16 +192,16 @@ sub file_save($$;$) # Params: 1. File::UseList object # 2. File to remove # -# Return: -nothing- +# Return: Status code (Boolean) sub file_unlock($$) { my ($uselist,$file) = @_; - $uselist->remove_file($file); - $uselist->save; + $uselist->remove_file($file) or return; + $uselist->save or return; - return; + return 1; } # it's true, baby ;-) -- 2.34.1