Исправлено сохранение mode и owner у файлов при использовании ._cfg0000

legacy27
Mike Hiretsky 6 years ago
parent e1100b7361
commit b92eed0b40

@ -1596,6 +1596,7 @@ class _file(_error):
self.nameFileConfig = os.path.abspath(nameFileConfig)
self.nameFileTemplate = os.path.abspath(nameFileTemplate)
self.F_TEMPL = self.openTemplFile(self.nameFileTemplate)
copy_stat = not os.path.exists(self.nameFileConfig)
if (not self.executeType and
typeFormat not in HParams.Formats.Executable):
self.F_CONF = self.__openConfFile(self.nameFileConfig)
@ -1606,11 +1607,25 @@ class _file(_error):
self.nameFileConfig)
if newBuffer is None:
self.textConfig = readFile(origConfigName)
if copy_stat:
self.copy_mod_own(origConfigName, self.nameFileConfig)
else:
self.textConfig = newBuffer
else:
self.textConfig = self.F_CONF.read()
def copy_mod_own(self, source, target):
try:
statdata = os.stat(source)
statdata_old = os.stat(target)
if statdata.st_mode != statdata_old.st_mode:
os.chmod(target, statdata.st_mode)
if (statdata.st_uid != statdata_old.st_uid or
statdata.st_gid != statdata_old.st_gid):
os.chown(target, statdata.st_uid, statdata.st_gid)
except OSError:
pass
def __del__(self):
self.closeFiles()
@ -4578,6 +4593,7 @@ gettext -d cl_template "$*"
try:
open(filename, 'w').write(
readFile(cfgs[filename][0][1]))
self.copy_mod_own(cfgs[filename][0][1], filename)
except Exception as e:
self.printERROR(str(e))
self.printWARNING(

Loading…
Cancel
Save