Fixed bug, wrong working with binary profiles using the profile settings 'mirror' and 'link'

master
Самоукин Алексей 15 years ago
parent 1ebb89d966
commit 27503759b1

@ -3407,6 +3407,25 @@ class profile(_file, _terms, xmlShare):
# Новый путь к оригинальному файлу
pathOldFile = os.path.join(pathRel,nameFile)
# В случае force
if objHeadNew.params.has_key("force"):
if os.path.islink(pathOldFile):
# удаляем ссылку
try:
os.unlink(pathOldFile)
except:
self.setError(_("Can not delete link: " ) +\
pathOldFile)
return (applyFiles, False)
if os.path.isfile(pathOldFile):
# удаляем файл
try:
os.remove(pathOldFile)
except:
self.setError(_("Can not delete file: " ) +\
pathOldFile)
return (applyFiles, False)
# Удаляем оригинальный файл
if objHeadNew.typeAppend == "remove":
if os.path.islink(pathOldFile):
@ -3414,7 +3433,7 @@ class profile(_file, _terms, xmlShare):
try:
os.unlink(pathOldFile)
except:
self.setError(_("Can not delete link: " ) +\
self.setError(_("Can not delete link: " ) +\
pathOldFile)
if os.path.isfile(pathOldFile):
# удаляем файл
@ -3467,21 +3486,6 @@ class profile(_file, _terms, xmlShare):
pathProg = os.getcwd()
os.chdir(pathLink)
pathOldFileExists = os.path.exists(pathOldFile)
# В случае force
if objHeadNew.params.has_key("force") and pathOldFileExists:
FO = self.openNewFile(pathOldFile)
buff = FO.read()
FO.close()
os.remove(pathOldFile)
fd = os.open(pathOldFile, os.O_CREAT)
os.close(fd)
os.chmod(pathOldFile, self._mode)
os.chown(pathOldFile, self._uid, self._gid)
FON = open (pathOldFile, "r+")
FON.write(buff)
FON.close()
# chmod - изменяем права
if objHeadNew.params.has_key("chmod"):
mode = self.__octToInt(objHeadNew.params['chmod'])
@ -3555,6 +3559,11 @@ class profile(_file, _terms, xmlShare):
applyFiles = [pathOldFile]
if pathProg:
os.chdir(pathProg)
# Если файлы заменяются не нужно их обрабатывать дальше
if objHeadNew.typeAppend == "replace" and\
not objHeadNew.params.has_key("symbolic") and\
objHeadNew.params.has_key("link"):
return (applyFiles, False)
return (applyFiles, objHeadNew)
def createNewClass(self, name, bases, attrs={}):
@ -3620,7 +3629,6 @@ class profile(_file, _terms, xmlShare):
copyFile = False
filesApply, objHeadNew = self.__getApplyHeadProfile(newFile, oldFile,
copyFile)
#print filesApply
if not objHeadNew:
return filesApply
# Флаг - кодировка с бинарными примесями у файла профиля включаем при
@ -5298,7 +5306,7 @@ class plasma(samba):
"""
_comment = "#"
configName = "kde"
configName = "plasma"
configVersion = "0.1"
reHeader = re.compile("^[\t ]*\[[^\[\]]+\].*\n?",re.M)
reBody = re.compile(".+",re.M|re.S)

Loading…
Cancel
Save