From c1be586f87e432ecc59888755a71d81cb7951efd Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 18 Dec 2017 13:27:14 -0500 Subject: [PATCH] Fix up the creation of new configuration files in sysadm-general (setConfFileValue()). --- src/server/library/sysadm-general.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/server/library/sysadm-general.cpp b/src/server/library/sysadm-general.cpp index ece4d4a..6ac29d9 100644 --- a/src/server/library/sysadm-general.cpp +++ b/src/server/library/sysadm-general.cpp @@ -189,12 +189,10 @@ bool General::setConfFileValue(QString fileName, QString oldKey, QString newKey, // Load the old file, find the oldKey, remove it and replace with newKey QFile file( oFileTmp ); - if ( ! file.open( QIODevice::ReadOnly ) ) - return false; - - QTextStream stream( &file ); - QString line; - while ( !stream.atEnd() ) { + if ( file.open( QIODevice::ReadOnly ) ){ + QTextStream stream( &file ); + QString line; + while ( !stream.atEnd() ) { line = stream.readLine(); // line of text excluding '\n' // Key is not found at all @@ -233,10 +231,12 @@ bool General::setConfFileValue(QString fileName, QString oldKey, QString newKey, continue; } + } + + file.close(); + }else if(file.exists()){ + return false; //could not read an existing file - permissions issue? } - - file.close(); - // Didn't find the key? Write it! if ( ! newKey.isEmpty() ) SavedFile << newKey;