Permalink
Browse files

finish merge

  • Loading branch information...
2 parents e86de36 + 552df70 commit 4021b68b8c5547a4a50e1e42c7314ef85fc7d4c5 @mdomsch committed with Dec 6, 2012
Showing with 28 additions and 0 deletions.
  1. +1 −0 S3/Config.py
  2. +27 −0 s3cmd
View
@@ -56,6 +56,7 @@ class Config(object):
]
delete_removed = False
delete_after = False
+ delete_after_fetch = False
_doc['delete_removed'] = "[sync] Remove remote S3 objects when local file has been deleted"
delay_updates = False
gpg_passphrase = ""
View
27 s3cmd
@@ -471,6 +471,9 @@ def cmd_object_get(args):
speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
output(u"File %s saved as '%s' (%d bytes in %0.1f seconds, %0.2f %sB/s)" %
(uri, destination, response["size"], response["elapsed"], speed_fmt[0], speed_fmt[1]))
+ if Config().delete_after_fetch:
+ s3.object_delete(uri)
+ output(u"File %s removed after fetch" % (uri))
def cmd_object_del(args):
for uri_str in args:
@@ -835,13 +838,33 @@ def cmd_sync_remote2local(args):
except S3DownloadError, e:
error(u"%s: download failed too many times. Skipping that file." % file)
continue
+<<<<<<< HEAD
speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
if not Config().progress_meter:
output(u"File '%s' stored as '%s' (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
(uri, unicodise(dst_file), response["size"], response["elapsed"], speed_fmt[0], speed_fmt[1],
seq_label))
total_size += response["size"]
return seq, total_size
+=======
+ # We have to keep repeating this call because
+ # Python 2.4 doesn't support try/except/finally
+ # construction :-(
+ try: dst_stream.close()
+ except: pass
+ except S3DownloadError, e:
+ error(u"%s: download failed too many times. Skipping that file." % file)
+ continue
+ speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
+ if not Config().progress_meter:
+ output(u"File '%s' stored as '%s' (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
+ (uri, unicodise(dst_file), response["size"], response["elapsed"], speed_fmt[0], speed_fmt[1],
+ seq_label))
+ if Config().delete_after_fetch:
+ s3.object_delete(uri)
+ output(u"File '%s' removed after syncing" % (uri))
+ total_size += response["size"]
+>>>>>>> nicjansma/master
total_size = 0
total_elapsed = 0.0
@@ -1682,9 +1705,13 @@ def main():
optparser.add_option( "--delete-removed", dest="delete_removed", action="store_true", help="Delete remote objects with no corresponding local file [sync]")
optparser.add_option( "--no-delete-removed", dest="delete_removed", action="store_false", help="Don't delete remote objects.")
+<<<<<<< HEAD
optparser.add_option( "--delete-after", dest="delete_after", action="store_true", help="Perform deletes after new uploads [sync]")
optparser.add_option( "--delay-updates", dest="delay_updates", action="store_true", help="Put all updated files into place at end [sync]")
optparser.add_option( "--add-destination", dest="additional_destinations", action="append", help="Additional destination for parallel uploads, in addition to last arg. May be repeated.")
+=======
+ optparser.add_option( "--delete-after-fetch", dest="delete_after_fetch", action="store_true", help="Delete remote objects after fetching to local file (only for [get] and [sync] commands).")
+>>>>>>> nicjansma/master
optparser.add_option("-p", "--preserve", dest="preserve_attrs", action="store_true", help="Preserve filesystem attributes (mode, ownership, timestamps). Default for [sync] command.")
optparser.add_option( "--no-preserve", dest="preserve_attrs", action="store_false", help="Don't store FS attributes")
optparser.add_option( "--exclude", dest="exclude", action="append", metavar="GLOB", help="Filenames and paths matching GLOB will be excluded from sync")

0 comments on commit 4021b68

Please sign in to comment.