Skip to content

Commit

Permalink
Make write_cfg more friendly to a symlinked lacuna.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
jmazon authored and tsee committed Dec 10, 2010
1 parent 80f4eea commit e31d258
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Games/Lacuna/Client.pm
Expand Up @@ -4,6 +4,7 @@ use strict;
use warnings; use warnings;
use Carp 'croak'; use Carp 'croak';
use File::Temp qw( tempfile ); use File::Temp qw( tempfile );
use Cwd qw( abs_path );


our $VERSION = '0.01'; our $VERSION = '0.01';
use constant DEBUG => 1; use constant DEBUG => 1;
Expand Down Expand Up @@ -156,6 +157,9 @@ sub write_cfg {
eval { eval {
my $target = $self->cfg_file(); my $target = $self->cfg_file();


# preserve symlinks: operate directly at destination
$target = abs_path $target;

# save data to a temporary, so we don't risk trashing the target # save data to a temporary, so we don't risk trashing the target
my ($tfh, $tempfile) = tempfile("$target.XXXXXXX"); # croaks on err my ($tfh, $tempfile) = tempfile("$target.XXXXXXX"); # croaks on err
print {$tfh} $yml or die $!; print {$tfh} $yml or die $!;
Expand Down

0 comments on commit e31d258

Please sign in to comment.