1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 01:06:17 +02:00

chmod handling

* prefer os.open instead of open && os.chmod
 * prefer os.fchmod when fd exists
This commit is contained in:
Michal Vyskocil 2014-01-06 11:12:02 +01:00
parent 550039f746
commit 5d5185cbc6
2 changed files with 3 additions and 3 deletions

View File

@ -570,8 +570,8 @@ def init_basicauth(config):
cookiejar.load(ignore_discard=True)
except IOError:
try:
open(cookie_file, 'w').close()
os.chmod(cookie_file, 0o600)
fd = os.open(cookie_file, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, mode=0o600)
os.close(fd)
except:
#print 'Unable to create cookiejar file: \'%s\'. Using RAM-based cookies.' % cookie_file
cookiejar = CookieJar()

View File

@ -4032,7 +4032,7 @@ def download(url, filename, progress_obj = None, mtime = None):
prefix = os.path.basename(filename)
path = os.path.dirname(filename)
(fd, tmpfile) = tempfile.mkstemp(dir=path, prefix = prefix, suffix = '.osctmp')
os.chmod(tmpfile, 0o644)
os.fchmod(fd, 0o644)
try:
o = os.fdopen(fd, 'wb')
for buf in streamfile(url, http_GET, BUFSIZE, progress_obj=progress_obj):