Clear quota usage immediately when data is deleted, triggering a recalc.

master
Moonchild 3 years ago
parent e092b46d79
commit 5f1f5f914b
No known key found for this signature in database
GPG Key ID: 26B40624BDBFD9F3

@ -280,6 +280,7 @@
if ($id) if ($id)
{ {
$db->delete_object($collection, $id); $db->delete_object($collection, $id);
$db->clear_quota_usage($username);
} }
else if ($collection) else if ($collection)
{ {
@ -293,12 +294,14 @@
$params['ids'], $params['ids'],
$params['index_above'], $params['index_below'] $params['index_above'], $params['index_below']
); );
$db->clear_quota_usage($username);
} }
else if($function == 'storage') // ich vermute mal storage reinigen else if($function == 'storage') // ich vermute mal storage reinigen
{ {
if (!array_key_exists('HTTP_X_CONFIRM_DELETE', $_SERVER)) if (!array_key_exists('HTTP_X_CONFIRM_DELETE', $_SERVER))
report_problem(WEAVE_ERROR_NO_OVERWRITE, 412); report_problem(WEAVE_ERROR_NO_OVERWRITE, 412);
$db->delete_storage($username); $db->delete_storage($username);
$db->clear_quota_usage($username);
} }
else else
{ {

@ -794,8 +794,25 @@ class WeaveStorage
return 0; return 0;
} }
return 1; return 1;
} }
function clear_quota_usage($username)
{
try
{
$update_statement = "update users set quota_usage = 0 where username = :username";
$sth = $this->_dbh->prepare($update_statement);
$sth->bindParam(':username', $username);
$sth->execute();
}
catch( PDOException $exception )
{
log_error("clear quota usage:" . $exception->getMessage());
return 0;
}
return 1;
}
function create_user($username, $password) function create_user($username, $password)
{ {
log_error("Create User - Username: ".$username."|".$password); log_error("Create User - Username: ".$username."|".$password);

Loading…
Cancel
Save