Merge pull request #338 from pilou-/apt_repository_filemode

apt_repository: fix file mode
reviewable/pr18780/r1
Toshio Kuratomi 10 years ago
commit 720632f568

@ -238,10 +238,6 @@ class SourcesList(object):
d, fn = os.path.split(filename)
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')
for n, valid, enabled, source, comment in sources:
chunks = []
@ -259,6 +255,10 @@ class SourcesList(object):
except IOError, err:
module.fail_json(msg="Failed to write to file %s: %s" % (tmp_path, unicode(err)))
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:
del self.files[filename]
if os.path.exists(filename):

Loading…
Cancel
Save