Changeset 25598

Show
Ignore:
Timestamp:
14.05.2012 18:45:15 (7 years ago)
Author:
ak19
Message:

When testing activate.pl with -keepold on Linux, it could not move the contents of the assoc subfolder of building and failed in the call to util::mv in util::mv_dir_contents. While the rename step was succeeding, the oriignal file remained in building, and Sam suspected the errors may be owing to the files being hardlinked. He suggested copying and deleting since renaming (and moving) these failed. Copying was no longer necessary, since the call rename() from mv() returned true for success. But deleting the file from building was necessary just as Sam said.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/util.pm

    r25579 r25598  
    174174        print STDERR "util::mv $file does not exist\n"; 
    175175    } else { 
    176         rename ($file, $tempdest); 
     176        if(!rename ($file, $tempdest)) { 
     177        print STDERR "**** Failed to rename $file to $tempdest\n"; 
     178        &File::Copy::copy($file, $tempdest); 
     179        &rm($file); 
     180        }  
     181        elsif(-e $file) { # rename (partially) succeeded) but srcfile still exists after rename 
     182        #print STDERR "*** srcfile $file still exists after rename to $tempdest\n"; 
     183        if(!-e $tempdest) { 
     184            print STDERR "@@@@ ERROR: $tempdest does not exist\n"; 
     185        } 
     186        # Sometimes the rename operation fails (as does File::Copy::move). 
     187        # This turns out to be because the files are hardlinked.  
     188        # Need to do a copy-delete in this case, however, the copy step is not necessary:  
     189        # the srcfile got renamed into tempdest, but srcfile itself still exists, delete it. 
     190        #&File::Copy::copy($file, $tempdest); 
     191 
     192        &rm($file);      
     193        } 
    177194    } 
    178195    } 
     
    215232                    }  
    216233                } else { # error 
    217                     print STDERR "ERROR. util::mv_dir_contents: subfolder $file still non-empty after moving contents to $dest_dir\n"; 
     234                    print STDERR "ERROR. util::mv_dir_contents: subfolder $file still non-empty after moving contents to $dest_subdir\n"; 
    218235                } 
    219236            } else { # process files and any directories that don't already exist with a simple move 
     
    226243        &mk_dir($dest_dir); 
    227244    } 
    228      
    229     #print STDERR "@@@@@ Copying files to: $dest_dir\n"; 
     245 
     246    #print STDERR "@@@@@ Copying files |".join(",", @full_path_files)."| to: $dest_dir\n"; 
     247 
    230248    if(@full_path_files) { # if non-empty, there's something to copy across 
    231249        &mv(@full_path_files, $dest_dir);