diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1009,6 +1009,7 @@ 'FileAllocateConduitAPIMethod' => 'applications/files/conduit/FileAllocateConduitAPIMethod.php', 'FileConduitAPIMethod' => 'applications/files/conduit/FileConduitAPIMethod.php', 'FileCreateMailReceiver' => 'applications/files/mail/FileCreateMailReceiver.php', + 'FileDeletionWorker' => 'applications/files/worker/FileDeletionWorker.php', 'FileDownloadConduitAPIMethod' => 'applications/files/conduit/FileDownloadConduitAPIMethod.php', 'FileInfoConduitAPIMethod' => 'applications/files/conduit/FileInfoConduitAPIMethod.php', 'FileMailReceiver' => 'applications/files/mail/FileMailReceiver.php', @@ -5253,6 +5254,7 @@ 'FileAllocateConduitAPIMethod' => 'FileConduitAPIMethod', 'FileConduitAPIMethod' => 'ConduitAPIMethod', 'FileCreateMailReceiver' => 'PhabricatorMailReceiver', + 'FileDeletionWorker' => 'PhabricatorWorker', 'FileDownloadConduitAPIMethod' => 'FileConduitAPIMethod', 'FileInfoConduitAPIMethod' => 'FileConduitAPIMethod', 'FileMailReceiver' => 'PhabricatorObjectMailReceiver', diff --git a/src/applications/files/controller/PhabricatorFileDeleteController.php b/src/applications/files/controller/PhabricatorFileDeleteController.php --- a/src/applications/files/controller/PhabricatorFileDeleteController.php +++ b/src/applications/files/controller/PhabricatorFileDeleteController.php @@ -25,7 +25,11 @@ } if ($request->isFormPost()) { - $file->delete(); + PhabricatorWorker::scheduleTask( + 'FileDeletionWorker', + array('fileID' => $id), + array('priority' => PhabricatorWorker::PRIORITY_DEFAULT)); + return id(new AphrontRedirectResponse())->setURI('/file/'); } diff --git a/src/applications/files/worker/FileDeletionWorker.php b/src/applications/files/worker/FileDeletionWorker.php new file mode 100644 --- /dev/null +++ b/src/applications/files/worker/FileDeletionWorker.php @@ -0,0 +1,36 @@ +file) { + return $this->file; + } + + $id = idx($this->getTaskData(), 'fileID'); + if (!$id) { + throw new PhabricatorWorkerPermanentFailureException( + pht('No "%s" in task data.', 'fileID')); + } + + $file = id(new PhabricatorFileQuery()) + ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->withIDs(array($id)) + ->executeOne(); + + if (!$file) { + throw new PhabricatorWorkerPermanentFailureException( + pht('File "%s" does not exist.', $id)); + } + + $this->file = $file; + return $file; + } + + public function doWork() { + $file = $this->loadFile(); + $file->delete(); // Requiescat in pace + } +}