Revision fed9c5c7 snf-pithos-backend/pithos/backends/modular.py
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
875 | 875 |
account_path, account_node = self._lookup_account(account, True) |
876 | 876 |
container_path, container_node = self._lookup_container( |
877 | 877 |
account, container) |
878 |
|
|
878 | 879 |
path, node = self._put_object_node( |
879 | 880 |
container_path, container_node, name) |
880 | 881 |
pre_version_id, dest_version_id = self._put_version_duplicate(user, node, src_node=src_node, size=size, type=type, hash=hash, checksum=checksum, is_copy=is_copy) |
... | ... | |
887 | 888 |
|
888 | 889 |
del_size = self._apply_versioning(account, container, pre_version_id) |
889 | 890 |
size_delta = size - del_size |
890 |
if not self.using_external_quotaholder: # Check account quota. |
|
891 |
if size_delta > 0: |
|
891 |
if size_delta > 0: |
|
892 |
# Check account quota. |
|
893 |
if not self.using_external_quotaholder: |
|
892 | 894 |
account_quota = long( |
893 | 895 |
self._get_policy(account_node, is_account_policy=True |
894 | 896 |
)['quota'] |
895 | 897 |
) |
896 |
account_usage = self._get_statistics(account_node)[1] + size_delta
|
|
898 |
account_usage = self._get_statistics(account_node)[1] |
|
897 | 899 |
if (account_quota > 0 and account_usage > account_quota): |
898 |
raise QuotaError('account quota exceeded: limit: %s, usage: %s' % ( |
|
899 |
account_quota, account_usage |
|
900 |
)) |
|
901 |
|
|
902 |
# Check container quota. |
|
903 |
container_quota = long( |
|
904 |
self._get_policy(container_node, is_account_policy=False |
|
905 |
)['quota'] |
|
906 |
) |
|
907 |
container_usage = self._get_statistics(container_node)[1] + size_delta |
|
908 |
if (container_quota > 0 and container_usage > container_quota): |
|
909 |
# This must be executed in a transaction, so the version is |
|
910 |
# never created if it fails. |
|
911 |
raise QuotaError('container quota exceeded: limit: %s, usage: %s' % ( |
|
912 |
container_quota, container_usage |
|
913 |
)) |
|
900 |
raise QuotaError( |
|
901 |
'Account quota exceeded: limit: %s, usage: %s' % ( |
|
902 |
account_quota, account_usage |
|
903 |
) |
|
904 |
) |
|
905 |
|
|
906 |
# Check container quota. |
|
907 |
container_quota = long( |
|
908 |
self._get_policy(container_node, is_account_policy=False |
|
909 |
)['quota'] |
|
910 |
) |
|
911 |
container_usage = self._get_statistics(container_node)[1] |
|
912 |
if (container_quota > 0 and container_usage > container_quota): |
|
913 |
# This must be executed in a transaction, so the version is |
|
914 |
# never created if it fails. |
|
915 |
raise QuotaError( |
|
916 |
'Container quota exceeded: limit: %s, usage: %s' % ( |
|
917 |
container_quota, container_usage |
|
918 |
) |
|
919 |
) |
|
914 | 920 |
|
915 | 921 |
self._report_size_change(user, account, size_delta, |
916 | 922 |
{'action': 'object update', 'path': path, |
Also available in: Unified diff