Commit f9cf9df4 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Merge branch 'feature-store' into develop

parents 58743792 2d158d8b
......@@ -1020,17 +1020,24 @@ class file_upload(_file_container_command):
'do not show progress bar',
('-N', '--no-progress-bar'),
default=False),
overwrite=FlagArgument('Force (over)write', ('-f', '--force'))
overwrite=FlagArgument('Force (over)write', ('-f', '--force')),
recursive=FlagArgument(
'Recursively upload directory *contents* + subdirectories',
('-R', '--recursive'))
)
def _check_container_limit(self, path):
cl_dict = self.client.get_container_limit()
container_limit = int(cl_dict['x-container-policy-quota'])
r = self.client.container_get()
used_bytes = sum(int(o['bytes']) for o in r.json)
path_size = get_path_size(path)
if path_size > container_limit:
raiseCLIError('Container(%s) limit(%s) < size(%s) of %s' % (
if path_size > (container_limit - used_bytes):
raiseCLIError(
'Container(%s) (limit(%s) - used(%s)) < size(%s) of %s' % (
self.client.container,
format_size(container_limit),
format_size(used_bytes),
format_size(path_size),
path),
importance=1, details=[
......@@ -1044,10 +1051,12 @@ class file_upload(_file_container_command):
def _path_pairs(self, local_path, remote_path):
"""Get pairs of local and remote paths"""
lpath = path.abspath(local_path)
self._check_container_limit(lpath)
short_path = lpath.split(path.sep)[-1]
rpath = remote_path or short_path
if path.isdir(lpath):
if not self['recursive']:
raiseCLIError('%s is a directory' % lpath, details=[
'Use -R to upload directory contents'])
robj = self.client.container_get(path=rpath)
if robj.json and not self['overwrite']:
raiseCLIError(
......@@ -1067,6 +1076,7 @@ class file_upload(_file_container_command):
except ClientError as ce:
if ce.status != 404:
raise
self._check_container_limit(lpath)
prev = ''
for top, subdirs, files in walk(lpath):
if top != prev:
......@@ -1099,6 +1109,7 @@ class file_upload(_file_container_command):
except ClientError as ce:
if ce.status != 404:
raise
self._check_container_limit(lpath)
yield open(lpath, 'rb'), rpath
@errors.generic.all
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment