Complete the diff generating functionality.

This commit is contained in:
yackob03 2013-10-18 14:31:14 -04:00
parent decb324411
commit a1164269be
6 changed files with 113 additions and 32 deletions

View file

@ -58,9 +58,9 @@ class Storage(object):
return '{0}/{1}/{2}/{3}/files.trie'.format(self.images, namespace,
repository, image_id)
def image_file_diffs_trie_path(self, namespace, repository, image_id):
return '{0}/{1}/{2}/{3}/diffs.pkl'.format(self.images, namespace,
repository, image_id)
def image_file_diffs_path(self, namespace, repository, image_id):
return '{0}/{1}/{2}/{3}/diffs.json'.format(self.images, namespace,
repository, image_id)
def get_content(self, path):
raise NotImplementedError
@ -71,6 +71,9 @@ class Storage(object):
def stream_read(self, path):
raise NotImplementedError
def stream_read_file(self, path):
raise NotImplementedError
def stream_write(self, path, fp):
raise NotImplementedError

View file

@ -38,6 +38,10 @@ class LocalStorage(Storage):
break
yield buf
def stream_read_file(self, path):
path = self._init_path(path)
return open(path, mode='rb')
def stream_write(self, path, fp):
# Size is mandatory
path = self._init_path(path, create=True)

View file

@ -60,6 +60,13 @@ class S3Storage(Storage):
break
yield buf
def stream_read_file(self, path):
path = self._init_path(path)
key = boto.s3.key.Key(self._s3_bucket, path)
if not key.exists():
raise IOError('No such key: \'{0}\''.format(path))
return key
def stream_write(self, path, fp):
# Minimum size of upload part size on S3 is 5MB
buffer_size = 5 * 1024 * 1024