Revision ccfd4e44

b/snf-pithos-app/pithos/api/functions.py
979 979
        raise ItemNotFound('Container does not exist')
980 980
    except ValueError:
981 981
        raise BadRequest('Invalid sharing header')
982
    except QuotaError:
983
        raise RequestEntityTooLarge('Quota exceeded')
982
    except QuotaError, e:
983
        raise RequestEntityTooLarge('Quota error: %s' % e)
984 984
    if not checksum and UPDATE_MD5:
985 985
        # Update the MD5 after the hashmap, as there may be missing hashes.
986 986
        checksum = hashmap_md5(request.backend, hashmap, size)
......
1027 1027
        raise Forbidden('Not allowed')
1028 1028
    except ItemNotExists:
1029 1029
        raise ItemNotFound('Container does not exist')
1030
    except QuotaError:
1031
        raise RequestEntityTooLarge('Quota exceeded')
1030
    except QuotaError, e:
1031
        raise RequestEntityTooLarge('Quota error: %s' % e)
1032 1032

  
1033 1033
    response = HttpResponse(status=201)
1034 1034
    response['ETag'] = checksum
......
1312 1312
        raise ItemNotFound('Container does not exist')
1313 1313
    except ValueError:
1314 1314
        raise BadRequest('Invalid sharing header')
1315
    except QuotaError:
1316
        raise RequestEntityTooLarge('Quota exceeded')
1315
    except QuotaError, e:
1316
        raise RequestEntityTooLarge('Quota error: %s' % e)
1317 1317
    if public is not None:
1318 1318
        try:
1319 1319
            request.backend.update_object_public(request.user_uniq, v_account,
b/snf-pithos-backend/pithos/backends/modular.py
853 853
                account_quota = long(self._get_policy(account_node)['quota'])
854 854
                account_usage = self._get_statistics(account_node)[1] + size_delta
855 855
                if (account_quota > 0 and account_usage > account_quota):
856
                    logger.error('account_quota: %s, account_usage: %s' % (
856
                    raise QuotaError('account quota exceeded: limit: %s, usage: %s' % (
857 857
                        account_quota, account_usage
858 858
                    ))
859
                    raise QuotaError
860 859

  
861 860
        # Check container quota.
862 861
        container_quota = long(self._get_policy(container_node)['quota'])
......
864 863
        if (container_quota > 0 and container_usage > container_quota):
865 864
            # This must be executed in a transaction, so the version is
866 865
            # never created if it fails.
867
            logger.error('container_quota: %s, container_usage: %s' % (
866
            raise QuotaError('container quota exceeded: limit: %s, usage: %s' % (
868 867
                container_quota, container_usage
869 868
            ))
870
            raise QuotaError
871 869

  
872 870
        self._report_size_change(user, account, size_delta,
873 871
                                 {'action': 'object update', 'path': path,
......
1292 1290
        if not self.using_external_quotaholder:
1293 1291
            return
1294 1292

  
1295
        serial = self.quotaholder.issue_commission(
1296
                context     =   {},
1297
                target      =   account,
1298
                key         =   '1',
1299
                clientkey   =   'pithos',
1300
                ownerkey    =   '',
1301
                name        =   details['path'] if 'path' in details else '',
1302
                provisions  =   (('pithos+', 'pithos+.diskspace', size),)
1303
        )
1304
        self.serials.append(serial)
1293
        try:
1294
            serial = self.quotaholder.issue_commission(
1295
                    context     =   {},
1296
                    target      =   account,
1297
                    key         =   '1',
1298
                    clientkey   =   'pithos',
1299
                    ownerkey    =   '',
1300
                    name        =   details['path'] if 'path' in details else '',
1301
                    provisions  =   (('pithos+', 'pithos+.diskspace', size),)
1302
            )
1303
        except BaseException, e:
1304
            raise QuotaError(e)
1305
        else:
1306
            self.serials.append(serial)
1305 1307

  
1306 1308
    def _report_object_change(self, user, account, path, details={}):
1307 1309
        details.update({'user': user})

Also available in: Unified diff