Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #136 from tjasond/master

mktemp permission issue, fix
  • Loading branch information...
commit 0bacdf47822a33b7616caacac45efff6d6bbbdeb 2 parents 7749423 + bdb0a65
@mludvig mludvig authored
Showing with 21 additions and 4 deletions.
  1. +21 −4 s3cmd
View
25 s3cmd
@@ -812,6 +812,15 @@ def cmd_sync_remote2local(args):
dst_stream.close()
# download completed, rename the file to destination
os.rename(chkptfname, dst_file)
+
+ # set permissions on destination file
+ original_umask = os.umask(0);
+ os.umask(original_umask);
+ mode = 0777 - original_umask;
+ debug(u"mode=%s" % oct(mode))
+
+ os.chmod(dst_file, mode);
+
debug(u"renamed chkptfname=%s to dst_file=%s" % (unicodise(chkptfname), unicodise(dst_file)))
if response['headers'].has_key('x-amz-meta-s3cmd-attrs') and cfg.preserve_attrs:
attrs = parse_attrs_header(response['headers']['x-amz-meta-s3cmd-attrs'])
@@ -823,7 +832,9 @@ def cmd_sync_remote2local(args):
os.utime(dst_file, (atime, mtime))
## FIXME: uid/gid / uname/gname handling comes here! TODO
except OSError, e:
- try: dst_stream.close()
+ try:
+ dst_stream.close()
+ os.remove(chkptfname)
except: pass
if e.errno == errno.EEXIST:
warning(u"%s exists - not overwriting" % (dst_file))
@@ -836,19 +847,25 @@ def cmd_sync_remote2local(args):
continue
raise e
except KeyboardInterrupt:
- try: dst_stream.close()
+ try:
+ dst_stream.close()
+ os.remove(chkptfname)
except: pass
warning(u"Exiting after keyboard interrupt")
return
except Exception, e:
- try: dst_stream.close()
+ try:
+ dst_stream.close()
+ os.remove(chkptfname)
except: pass
error(u"%s: %s" % (file, e))
continue
# We have to keep repeating this call because
# Python 2.4 doesn't support try/except/finally
# construction :-(
- try: dst_stream.close()
+ try:
+ dst_stream.close()
+ os.remove(chkptfname)
except: pass
except S3DownloadError, e:
error(u"%s: download failed too many times. Skipping that file." % file)
Please sign in to comment.
Something went wrong with that request. Please try again.