xmltv/lib Configure.pm,1.8,1.9
Geoff <[email protected]>
| Newsgroups | gmane.comp.tv.xmltv.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/xmltv/xmltv/lib
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv620
Modified Files:
Configure.pm
Log Message:
write the config file atomically (bug #178)
Index: Configure.pm
===================================================================
RCS file: /cvsroot/xmltv/xmltv/lib/Configure.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Configure.pm 8 Jan 2014 11:27:50 -0000 1.8
--- Configure.pm 25 May 2014 10:44:52 -0000 1.9
***************
*** 4,8 ****
# 0.005065 : can use 'constant' in write_string()
# 0.005065 : comments in config file not restricted to starting in first column
! our $VERSION = 0.005065;
BEGIN {
--- 4,9 ----
# 0.005065 : can use 'constant' in write_string()
# 0.005065 : comments in config file not restricted to starting in first column
! # 0.005066 : make writes to the config-file atomic
! our $VERSION = 0.005066;
BEGIN {
***************
*** 116,121 ****
my( $conf, $config_file ) = @_;
! open OUT, "> $config_file"
! or die "Failed to open $config_file for writing.";
foreach my $key (keys %{$conf})
--- 117,126 ----
my( $conf, $config_file ) = @_;
! # Test if configuration file is writeable
! if (-f $config_file && !(-w $config_file)) { die "Cannot write to $config_file"; }
!
! # Create temporary configuration file.
! open OUT, "> $config_file.TMP"
! or die "Failed to open $config_file.TMP for writing.";
foreach my $key (keys %{$conf})
***************
*** 141,144 ****
--- 146,152 ----
close OUT;
+
+ # Store temporary configuration file
+ rename "$config_file.TMP", $config_file or die "Failed to write to $config_file";
}
***************
*** 173,183 ****
my $nextstage = 'start';
! # Clear the configuration file.
! open OUT, "> $conffile" or die "Failed to write to $conffile";
close OUT;
do
{
! my $stage = &$stagesub( $nextstage, LoadConfig( $conffile ) );
$nextstage = configure_stage( $stage, $conffile, $lang );
} while ($nextstage ne "select-channels" );
--- 181,194 ----
my $nextstage = 'start';
! # Test if configuration file is writeable
! if (-f $conffile && !(-w $conffile)) { die "Cannot write to $conffile"; }
!
! # Create temporary configuration file.
! open OUT, "> $conffile.TMP" or die "Failed to write to $conffile.TMP";
close OUT;
do
{
! my $stage = &$stagesub( $nextstage, LoadConfig( "$conffile.TMP" ) );
$nextstage = configure_stage( $stage, $conffile, $lang );
} while ($nextstage ne "select-channels" );
***************
*** 186,194 ****
# channel selection if the configuration is using lineups where
# channels are determined automatically
! my $conf = LoadConfig( $conffile );
if (! exists $conf->{lineup}) {
my $channels = &$listsub( $conf, $opt );
select_channels( $channels, $conffile, $lang );
}
}
--- 197,208 ----
# channel selection if the configuration is using lineups where
# channels are determined automatically
! my $conf = LoadConfig( "$conffile.TMP" );
if (! exists $conf->{lineup}) {
my $channels = &$listsub( $conf, $opt );
select_channels( $channels, $conffile, $lang );
}
+
+ # Store temporary configuration file
+ rename "$conffile.TMP", $conffile or die "Failed to write to $conffile";
}
***************
*** 199,204 ****
my $nextstage = undef;
! open OUT, ">> $conffile"
! or die "Failed to open $conffile for writing";
my $xml = XML::LibXML->new;
--- 213,218 ----
my $nextstage = undef;
! open OUT, ">> $conffile.TMP"
! or die "Failed to open $conffile.TMP for writing";
my $xml = XML::LibXML->new;
***************
*** 296,301 ****
my( $channels, $conffile, $lang ) = @_;
! open OUT, ">> $conffile"
! or die "Failed to open $conffile for writing";
my $xml = XML::LibXML->new;
--- 310,315 ----
my( $channels, $conffile, $lang ) = @_;
! open OUT, ">> $conffile.TMP"
! or die "Failed to open $conffile.TMP for writing";
my $xml = XML::LibXML->new;
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs