mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-26 11:10:16 +01:00
Summary: Deletion is a possibly time-intensive process, especially with large files that are backed by high-latency, chunked storage (such as S3). Even ~200mb objects take minutes to delete, which makes for an unhappy experience. Fixes T10828. Test Plan: Delete a large file, and stare in awe of the swiftness with which I am redirected to the main file application. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: thoughtpolice, Korvin Maniphest Tasks: T10828 Differential Revision: https://secure.phabricator.com/D15743
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
final class PhabricatorFileDeleteController extends PhabricatorFileController {
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$viewer = $request->getViewer();
|
|
$id = $request->getURIData('id');
|
|
|
|
$file = id(new PhabricatorFileQuery())
|
|
->setViewer($viewer)
|
|
->withIDs(array($id))
|
|
->withIsDeleted(false)
|
|
->requireCapabilities(
|
|
array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
))
|
|
->executeOne();
|
|
if (!$file) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
if (($viewer->getPHID() != $file->getAuthorPHID()) &&
|
|
(!$viewer->getIsAdmin())) {
|
|
return new Aphront403Response();
|
|
}
|
|
|
|
if ($request->isFormPost()) {
|
|
// Mark the file for deletion, save it, and schedule a worker to
|
|
// sweep by later and pick it up.
|
|
$file->setIsDeleted(true)->save();
|
|
|
|
PhabricatorWorker::scheduleTask(
|
|
'FileDeletionWorker',
|
|
array('objectPHID' => $file->getPHID()),
|
|
array('priority' => PhabricatorWorker::PRIORITY_BULK));
|
|
|
|
return id(new AphrontRedirectResponse())->setURI('/file/');
|
|
}
|
|
|
|
return $this->newDialog()
|
|
->setTitle(pht('Really delete file?'))
|
|
->appendChild(hsprintf(
|
|
'<p>%s</p>',
|
|
pht(
|
|
'Permanently delete "%s"? This action can not be undone.',
|
|
$file->getName())))
|
|
->addSubmitButton(pht('Delete'))
|
|
->addCancelButton($file->getInfoURI());
|
|
}
|
|
}
|