diff options
author | James Saryerwinnie <js@jamesls.com> | 2012-09-06 17:03:13 -0700 |
---|---|---|
committer | James Saryerwinnie <js@jamesls.com> | 2012-09-06 17:03:13 -0700 |
commit | 15a370b45e422dbd551bc2aafbefc194b51eed26 (patch) | |
tree | f61478e4c1b437de2076bf39080c6134207f6852 | |
parent | f1b007e6c8f29096e5e20266c66df873b777dc4e (diff) | |
download | boto-15a370b45e422dbd551bc2aafbefc194b51eed26.tar.gz |
Allow single op threshold to be configurable
This is the threshold at which the Vault class will
use a multipart upload instead of a single operation
upload.
-rw-r--r-- | boto/glacier/vault.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/boto/glacier/vault.py b/boto/glacier/vault.py index f2c5ef3e..d51bcbf2 100644 --- a/boto/glacier/vault.py +++ b/boto/glacier/vault.py @@ -26,10 +26,12 @@ from .writer import Writer, bytes_to_hex, chunk_hashes, tree_hash import hashlib import os.path +_MEGABYTE = 1024 * 1024 class Vault(object): - DefaultPartSize = 4 * 1024 * 1024 # 128MB + DefaultPartSize = 4 * _MEGABYTE + SingleOperationThreshold = 100 * _MEGABYTE ResponseDataElements = (('VaultName', 'name', None), ('VaultARN', 'arn', None), @@ -70,8 +72,7 @@ class Vault(object): :rtype: str :return: The archive id of the newly created archive """ - megabyte = 1024 * 1024 - if os.path.getsize(filename) > 100 * megabyte: + if os.path.getsize(filename) > self.SingleOperationThreshold: return self.create_archive_from_file(filename) return self._upload_archive_single_operation(filename) @@ -134,7 +135,7 @@ class Vault(object): writer = self.create_archive_writer() while True: - data = file_obj.read(1024 * 1024 * 4) + data = file_obj.read(self.DefaultPartSize) if not data: break writer.write(data) |