Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15490253
D15743.id37938.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D15743.id37938.diff
View Options
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 @@
+<?php
+
+final class FileDeletionWorker extends PhabricatorWorker {
+
+ private $file;
+
+ private function loadFile() {
+ if ($this->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
+ }
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 12, 3:41 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7321573
Default Alt Text
D15743.id37938.diff (2 KB)
Attached To
Mode
D15743: Make daemons perform file deletion
Attached
Detach File
Event Timeline
Log In to Comment