@@ -747,24 +747,26 @@ def do_journald(self, listItem=None):
747747 if not listItem == None :
748748 self .set_value (listItem )
749749 if self .struct ['journal' ]['settings' ]['journal_persistent' ]['value' ] == '0' :
750- try :
750+ if os . path . isfile ( self . JOURNALD_CONFIG_FILE ) :
751751 os .remove (self .JOURNALD_CONFIG_FILE )
752- except :
753- pass
754752 else :
755- config_file = open (self .JOURNALD_CONFIG_FILE , 'w' )
756- config_file .write ("# SPDX-License-Identifier: GPL-2.0-or-later\n " +
757- "# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)\n \n " +
758- "# This file is generated automatically, don't modify.\n \n " +
759- "[Journal]\n " )
760-
761753 size = self .struct ['journal' ]['settings' ]['journal_size' ]['value' ].replace (' MiB' , 'M' )
762- config_file .write (f"SystemMaxUse={ size } \n " +
763- "MaxRetentionSec=0\n " )
764- if self .struct ['journal' ]['settings' ]['journal_rate_limit' ]['value' ] == '1' :
765- config_file .write ("RateLimitInterval=0\n " +
766- "RateLimitBurst=0\n " )
767- config_file .close ()
754+ journal_config = f"""\
755+ # SPDX-License-Identifier: GPL-2.0-only
756+ # Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
757+
758+ # This file is generated automatically. Do not modify.
759+
760+ [Journal]
761+ SystemMaxUse={ size }
762+ MaxRetentionSec=0
763+ { 'RateLimitInterval=0' if self .struct ['journal' ]['settings' ]['journal_rate_limit' ]['value' ] == '1' else '' }
764+ { 'RateLimitBurst=0' if self .struct ['journal' ]['settings' ]['journal_rate_limit' ]['value' ] == '1' else '' }
765+ """
766+ # remove trailing whitespace, then add one new line
767+ journal_config = f'{ journal_config .rstrip ()} { chr (10 )} '
768+ with open (self .JOURNALD_CONFIG_FILE , 'w' ) as config_file :
769+ config_file .write (journal_config )
768770
769771 @log .log_function ()
770772 def do_wizard (self ):
0 commit comments