Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added cleanup of temp file if error or keyboard interrupt occurs duri…

…ng transfer.
  • Loading branch information...
commit f3607dfb1547b990d2cdcadbf3abf3f082c2bf56 1 parent 640a885
Jason Dalton authored
Showing with 12 additions and 4 deletions.
  1. +12 −4 s3cmd
View
16 s3cmd
@@ -827,7 +827,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(temp_file)
except: pass
if e.errno == errno.EEXIST:
warning(u"%s exists - not overwriting" % (dst_file))
@@ -840,19 +842,25 @@ def cmd_sync_remote2local(args):
continue
raise e
except KeyboardInterrupt:
- try: dst_stream.close()
+ try:
+ dst_stream.close()
+ os.remove(temp_file)
except: pass
warning(u"Exiting after keyboard interrupt")
return
except Exception, e:
- try: dst_stream.close()
+ try:
+ dst_stream.close()
+ os.remove(temp_file)
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(temp_file)
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.