File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
src/DIRAC/ConfigurationSystem/private Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 77import _thread
88import time
99import datetime
10+ import secrets
1011
1112from diraccfg import CFG
1213
@@ -342,11 +343,15 @@ def __backupCurrentConfiguration(self, backupName):
342343
343344 def writeRemoteConfigurationToDisk (self , backupName = False ):
344345 configurationFile = os .path .join (DIRAC .rootPath , "etc" , f"{ self .getName ()} .cfg" )
346+ configurationFileTmp = f"{ configurationFile } .{ secrets .token_hex (8 )} "
345347 try :
346- with open (configurationFile , "w" ) as fd :
348+ with open (configurationFileTmp , "w" ) as fd :
347349 fd .write (str (self .remoteCFG ))
350+ os .rename (configurationFileTmp , configurationFile )
348351 except Exception as e :
349352 gLogger .fatal ("Cannot write new configuration to disk!" , f"file { configurationFile } exception { repr (e )} " )
353+ if os .path .isfile (configurationFileTmp ):
354+ os .remove (configurationFileTmp )
350355 return S_ERROR (f"Can't write cs file { configurationFile } !: { repr (e ).replace (',)' , ')' )} " )
351356 if backupName :
352357 self .__backupCurrentConfiguration (backupName )
You can’t perform that action at this time.
0 commit comments