Commit 2b74fc1d authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Take into account container used bytes in upload

Before uploading, check if there is enough remaining space on container
remaning space = container limit - container used bytes
parent 9895158e
......@@ -1026,11 +1026,15 @@ class file_upload(_file_container_command):
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=[
......
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