Allow users to delete their own packages

Allow users to remove their own package bases for a short period of time
after initial submission (defaults to one day).

Implements FS#43648.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2015-03-04 12:15:05 +01:00
parent 84061604aa
commit 5dca715c46
3 changed files with 18 additions and 2 deletions

View file

@ -25,6 +25,7 @@ max_rpc_results = 5000
aur_request_ml = aur-requests@archlinux.org aur_request_ml = aur-requests@archlinux.org
request_idle_time = 1209600 request_idle_time = 1209600
auto_orphan_age = 15552000 auto_orphan_age = 15552000
auto_delete_age = 86400
[auth] [auth]
key-prefixes = ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 ssh-ed25519 key-prefixes = ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 ssh-ed25519

View file

@ -436,11 +436,12 @@ function pkgbase_unflag($base_ids) {
* @param array $base_ids Array of package base IDs to delete * @param array $base_ids Array of package base IDs to delete
* @param int $merge_base_id Package base to merge the deleted ones into * @param int $merge_base_id Package base to merge the deleted ones into
* @param int $via Package request to close upon deletion * @param int $via Package request to close upon deletion
* @param bool $grant Allow anyone to delete the package base
* *
* @return array Tuple of success/failure indicator and error message * @return array Tuple of success/failure indicator and error message
*/ */
function pkgbase_delete ($base_ids, $merge_base_id, $via) { function pkgbase_delete ($base_ids, $merge_base_id, $via, $grant=false) {
if (!has_credential(CRED_PKGBASE_DELETE)) { if (!$grant && !has_credential(CRED_PKGBASE_DELETE)) {
return array(false, __("You do not have permission to delete packages.")); return array(false, __("You do not have permission to delete packages."));
} }

View file

@ -184,6 +184,7 @@ function pkgreq_file($ids, $type, $merge_into, $comments) {
" Request for " . $row['Name'], $body, $headers); " Request for " . $row['Name'], $body, $headers);
$auto_orphan_age = config_get('options', 'auto_orphan_age'); $auto_orphan_age = config_get('options', 'auto_orphan_age');
$auto_delete_age = config_get('options', 'auto_delete_age');
$details = pkgbase_get_details($base_id); $details = pkgbase_get_details($base_id);
if ($type == 'orphan' && $details['OutOfDateTS'] > 0 && if ($type == 'orphan' && $details['OutOfDateTS'] > 0 &&
time() - $details['OutOfDateTS'] >= $auto_orphan_age && time() - $details['OutOfDateTS'] >= $auto_orphan_age &&
@ -201,6 +202,19 @@ function pkgreq_file($ids, $type, $merge_into, $comments) {
$q = "UPDATE PackageBases SET MaintainerUID = NULL "; $q = "UPDATE PackageBases SET MaintainerUID = NULL ";
$q.= "WHERE ID = " . $base_id; $q.= "WHERE ID = " . $base_id;
$dbh->exec($q); $dbh->exec($q);
} else if ($type == 'deletion' && $details['MaintainerUID'] == $uid &&
$details['SubmittedTS'] > 0 && $auto_delete_age > 0 &&
time() - $details['SubmittedTS'] <= $auto_delete_age) {
/*
* Close package request. NOTE: This needs to happen *before*
* the actual deletion operation. Otherwise, the former
* maintainer will not be included in the Cc list of the
* request notification email.
*/
pkgreq_close($request_id, "accepted",
"Deletion of a fresh package requested by its " .
"current maintainer.", true);
pkgbase_delete(array($base_id), NULL, NULL, true);
} }
return array(true, __("Added request successfully.")); return array(true, __("Added request successfully."));