Improve save_config()
authorDavor Ocelic <docelic@crystallabs.io>
Fri, 03 May 2019 19:23:54 +0200
changeset 113 ce001854d4b8
parent 112 32f396697fb3
child 114 35b7143830e8
Improve save_config()
shelldap
--- a/shelldap	Tue Apr 30 12:07:28 2019 +0200
+++ b/shelldap	Fri May 03 19:23:54 2019 +0200
@@ -2608,13 +2608,14 @@
 {
 	my $confpath = shift;
 
-	my %conf2 = %$conf;
-	if( $confpath eq $conf->{configfile}) {
-		delete $conf2{'configfile'}
+	# This check is currently unnecessary because the comparison will always
+	# be true, but is left here for effect of least surprise in the future.
+	if( defined($conf->{'configfile'}) and ($confpath eq $conf->{'configfile'})) {
+		delete $conf->{'configfile'}
 	}
 
-	YAML::Syck::DumpFile( $conf->{'configfile'}, \%conf2 );
-	chmod 0600, $conf->{'configfile'};
+	YAML::Syck::DumpFile( $confpath, $conf );
+	chmod 0600, $confpath;
 
 	return 1;
 }