Ignore:
Timestamp:
06/07/13 10:48:39 (7 years ago)
Author:
jmt12
Message:

Trying to streamline the error messages from failing to link (otherwise I get a zillion messages about being unable to link from /tmp to /share as they are different physical media, for instance)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/parallel-building/trunk/src/perllib/FileUtils/LocalFS.pm

    r27567 r27569  
    2828# Pragma
    2929use strict;
     30
     31
     32# Globals
     33my $paths_we_cannot_link_from = {};
    3034
    3135
     
    193197  }
    194198
     199  my $error_message = ucfirst(lc($mode)) . ' link failed';
    195200  if ($ENV{'GSDLOS'} =~ /^windows$/i)
    196201  {
    197202    # symlink not supported on windows
    198     &FileUtils::printWarning('Symlink not supported on windows');
     203    $error_message = 'Symlink not supported on windows';
    199204  }
    200205  elsif ($mode eq 'HARD')
    201206  {
    202     if (!eval {link($src, $dest)})
    203     {
    204       &FileUtils::printWarning('Unable to create hard link: ' . $dest);
    205     }
     207    link($src, $dest);
     208    #if (!eval {link($src, $dest)})
     209    #{
     210    #  &FileUtils::printWarning('Unable to create hard link: ' . $dest);
     211    #}
    206212  }
    207213  elsif ($mode eq 'SOFT')
    208214  {
    209     if (!eval {symlink($src, $dest)})
    210     {
    211       &FileUtils::printWarning('Unable to create soft link: ' . $src);
    212     }
     215    symlink($src, $dest);
     216    #if (!eval {symlink($src, $dest)})
     217    #{
     218    #  &FileUtils::printWarning('Unable to create soft link: ' . $src);
     219    #}
    213220  }
    214221  else
    215222  {
    216     &FileUtils::printError('Unknown mode requested: ' . $mode);
     223    $error_message = 'Unknown mode requested: ' . $mode;
    217224  }
    218225  if (!-e $dest)
    219226  {
    220     &FileUtils::printWarning('linkFile', 'Link failed. Attempting to copy instead.');
     227    # Determine the top source path
     228    my ($src_root) = $src =~ /^([a-z]:\\|\/[^\/]+)/i;
     229    # If we haven't warned about this yet, warn now and record that we've
     230    # warned. I want to let the user know what has happened, but without
     231    # bombarding them with a thousand warning messages...
     232    if (!defined $paths_we_cannot_link_from->{$src_root})
     233    {
     234      &FileUtils::printWarning($error_message . '. Will attempt to copy from: ' . $src_root);
     235      $paths_we_cannot_link_from->{$src_root} = 1;
     236    }
    221237    &File::Copy::copy ($src, $dest);
    222238  }
Note: See TracChangeset for help on using the changeset viewer.