summary | 
shortlog | 
log | 
commit | commitdiff | 
tree
raw | 
patch | 
inline | side by side (from parent 1: 
7897c60)
 
- 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
 # Dev-Editor's main program
 #
 # Author:        Patrick Canterino <patrick@patshaping.de>
 # Dev-Editor's main program
 #
 # Author:        Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2005-01-06
+# Last modified: 2005-02-10
               version      => $VERSION,
               configfile   => CONFIGFILE);
 
               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;
 
 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.
 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
 
 # End of configuration file
\ No newline at end of file
 
 # Execute Dev-Editor's commands
 #
 # Author:        Patrick Canterino <patrick@patshaping.de>
 # Execute Dev-Editor's commands
 #
 # Author:        Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2005-01-24
+# Last modified: 2005-02-10
- $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
 
 
  # ... and show the editing form
 
 {
  my ($data,$config) = @_;
  my $virtual        = $data->{'virtual'};
 {
  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});
  # No other user of Dev-Editor will access the file during this
  # routine because of the concept of File::UseList.
 
  # 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'}});
 
  if($data->{'cgi'}->param('confirmed'))
  {
 
  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
   return devedit_reload({command => 'show', file => $dir});
  }
  else
 
 # using only one command
 #
 # Author:        Patrick Canterino <patrick@patshaping.de>
 # using only one command
 #
 # Author:        Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2005-02-09
+# Last modified: 2005-02-10
 # Params: 1. File::UseList object
 #         2. File to remove
 #
 # Params: 1. File::UseList object
 #         2. File to remove
 #
+# Return: Status code (Boolean)
 
 sub file_unlock($$)
 {
  my ($uselist,$file) = @_;
 
 
 sub file_unlock($$)
 {
  my ($uselist,$file) = @_;
 
- $uselist->remove_file($file);
- $uselist->save;
+ $uselist->remove_file($file) or return;
+ $uselist->save               or return;