Page MenuHomePhabricator

D14075.diff
No OneTemporary

D14075.diff

diff --git a/src/upload/ArcanistFileDataRef.php b/src/upload/ArcanistFileDataRef.php
--- a/src/upload/ArcanistFileDataRef.php
+++ b/src/upload/ArcanistFileDataRef.php
@@ -27,6 +27,8 @@
private $errors = array();
private $phid;
private $fileHandle;
+ private $deleteAfterEpoch;
+ private $viewPolicy;
/* -( Configuring File References )---------------------------------------- */
@@ -107,6 +109,48 @@
}
+ /**
+ * @task config
+ */
+ public function setViewPolicy($view_policy) {
+ $this->viewPolicy = $view_policy;
+ return $this;
+ }
+
+
+ /**
+ * @task config
+ */
+ public function getViewPolicy() {
+ return $this->viewPolicy;
+ }
+
+
+ /**
+ * Configure a file to be temporary instead of permanent.
+ *
+ * By default, files are retained indefinitely until explicitly deleted. If
+ * you want to upload a temporary file instead, you can specify an epoch
+ * timestamp. The file will be deleted after this time.
+ *
+ * @param int Epoch timestamp to retain the file until.
+ * @return this
+ * @task config
+ */
+ public function setDeleteAfterEpoch($epoch) {
+ $this->deleteAfterEpoch = $epoch;
+ return $this;
+ }
+
+
+ /**
+ * @task config
+ */
+ public function getDeleteAfterEpoch() {
+ return $this->deleteAfterEpoch;
+ }
+
+
/* -( Handling Upload Results )-------------------------------------------- */
diff --git a/src/upload/ArcanistFileUploader.php b/src/upload/ArcanistFileUploader.php
--- a/src/upload/ArcanistFileUploader.php
+++ b/src/upload/ArcanistFileUploader.php
@@ -27,7 +27,6 @@
private $conduit;
private $files;
- private $config = array();
/* -( Configuring the Uploader )------------------------------------------- */
@@ -79,33 +78,6 @@
}
- /**
- * Configure a file to be temporary instead of permanent.
- *
- * By default, files are retained indefinitely until explicitly deleted. If
- * you want to upload a temporary file instead, you can specify an epoch
- * timestamp. The file will be deleted after this time.
- *
- * @param string Key identifying the file you want to make temporary, as
- * passed to @{method:addFile}.
- * @param int Epoch timestamp to retain the file until.
- * @return this
- * @task add
- */
- public function setDeleteFileAfterEpoch($file_key, $epoch) {
- if (empty($this->files[$file_key])) {
- throw new Exception(
- pht(
- 'No file with given key ("%s") has been added to this uploader.',
- $file_key));
- }
-
- $this->config[$file_key]['deleteAfterEpoch'] = $epoch;
-
- return $this;
- }
-
-
/* -( Uploading Files )---------------------------------------------------- */
@@ -144,19 +116,22 @@
$conduit = $this->conduit;
$futures = array();
foreach ($files as $key => $file) {
- $config = idx($this->config, $key, array());
-
$params = array(
'name' => $file->getName(),
'contentLength' => $file->getByteSize(),
'contentHash' => $file->getContentHash(),
);
- $delete_after = idx($config, 'deleteAfterEpoch');
+ $delete_after = $file->getDeleteAfterEpoch();
if ($delete_after !== null) {
$params['deleteAfterEpoch'] = $delete_after;
}
+ $view_policy = $file->getViewPolicy();
+ if ($view_policy !== null) {
+ $params['viewPolicy'] = $view_policy;
+ }
+
$futures[$key] = $conduit->callMethod('file.allocate', $params);
}
diff --git a/src/workflow/ArcanistUploadWorkflow.php b/src/workflow/ArcanistUploadWorkflow.php
--- a/src/workflow/ArcanistUploadWorkflow.php
+++ b/src/workflow/ArcanistUploadWorkflow.php
@@ -69,13 +69,12 @@
->setName(basename($path))
->setPath($path);
- $uploader->addFile($file, $key);
-
if ($is_temporary) {
- $uploader->setDeleteFileAfterEpoch(
- $key,
- time() + phutil_units('24 hours in seconds'));
+ $expires_at = time() + phutil_units('24 hours in seconds');
+ $file->setDeleteAfterEpoch($expires_at);
}
+
+ $uploader->addFile($file);
}
$files = $uploader->uploadFiles();

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 14, 11:57 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7388964
Default Alt Text
D14075.diff (4 KB)

Event Timeline