apt_repository: fix file mode
'set_mode_if_different' method should be called on dest filename and after 'atomic_move' method
This commit is contained in:
parent
b318bc8b43
commit
c366e7acb2
1 changed files with 4 additions and 4 deletions
|
@ -238,10 +238,6 @@ class SourcesList(object):
|
||||||
d, fn = os.path.split(filename)
|
d, fn = os.path.split(filename)
|
||||||
fd, tmp_path = tempfile.mkstemp(prefix=".%s-" % fn, dir=d)
|
fd, tmp_path = tempfile.mkstemp(prefix=".%s-" % fn, dir=d)
|
||||||
|
|
||||||
# allow the user to override the default mode
|
|
||||||
this_mode = module.params['mode']
|
|
||||||
module.set_mode_if_different(tmp_path, this_mode, False)
|
|
||||||
|
|
||||||
f = os.fdopen(fd, 'w')
|
f = os.fdopen(fd, 'w')
|
||||||
for n, valid, enabled, source, comment in sources:
|
for n, valid, enabled, source, comment in sources:
|
||||||
chunks = []
|
chunks = []
|
||||||
|
@ -259,6 +255,10 @@ class SourcesList(object):
|
||||||
except IOError, err:
|
except IOError, err:
|
||||||
module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, unicode(err)))
|
module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, unicode(err)))
|
||||||
module.atomic_move(tmp_path, filename)
|
module.atomic_move(tmp_path, filename)
|
||||||
|
|
||||||
|
# allow the user to override the default mode
|
||||||
|
this_mode = module.params['mode']
|
||||||
|
module.set_mode_if_different(filename, this_mode, False)
|
||||||
else:
|
else:
|
||||||
del self.files[filename]
|
del self.files[filename]
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
|
|
Loading…
Reference in a new issue