Page MenuHomePhabricator

D11917.diff
No OneTemporary

D11917.diff

diff --git a/src/applications/files/controller/PhabricatorFileInfoController.php b/src/applications/files/controller/PhabricatorFileInfoController.php
--- a/src/applications/files/controller/PhabricatorFileInfoController.php
+++ b/src/applications/files/controller/PhabricatorFileInfoController.php
@@ -222,6 +222,15 @@
$finfo->addProperty(pht('Viewable Image'), $image_string);
$finfo->addProperty(pht('Cacheable'), $cache_string);
+ $builtin = $file->getBuiltinName();
+ if ($builtin === null) {
+ $builtin_string = pht('No');
+ } else {
+ $builtin_string = $builtin;
+ }
+
+ $finfo->addProperty(pht('Builtin'), $builtin_string);
+
$storage_properties = new PHUIPropertyListView();
$box->addPropertyList($storage_properties, pht('Storage'));
diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php
--- a/src/applications/files/storage/PhabricatorFile.php
+++ b/src/applications/files/storage/PhabricatorFile.php
@@ -14,6 +14,7 @@
* | isExplicitUpload | Used to show users files they explicitly uploaded.
* | canCDN | Allows the file to be cached and delivered over a CDN.
* | mime-type | Optional, explicit file MIME type.
+ * | builtin | Optional filename, identifies this as a builtin.
*
*/
final class PhabricatorFile extends PhabricatorFileDAO
@@ -31,6 +32,7 @@
const METADATA_IMAGE_WIDTH = 'width';
const METADATA_IMAGE_HEIGHT = 'height';
const METADATA_CAN_CDN = 'canCDN';
+ const METADATA_BUILTIN = 'builtin';
protected $name;
protected $mimeType;
@@ -895,6 +897,8 @@
$params = array(
'name' => $name,
'ttl' => time() + (60 * 60 * 24 * 7),
+ 'canCDN' => true,
+ 'builtin' => $name,
);
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
@@ -981,6 +985,19 @@
return $this;
}
+ public function isBuiltin() {
+ return ($this->getBuiltinName() !== null);
+ }
+
+ public function getBuiltinName() {
+ return idx($this->metadata, self::METADATA_BUILTIN);
+ }
+
+ public function setBuiltinName($name) {
+ $this->metadata[self::METADATA_BUILTIN] = $name;
+ return $this;
+ }
+
protected function generateOneTimeToken() {
$key = Filesystem::readRandomCharacters(16);
@@ -1078,6 +1095,11 @@
$this->setCanCDN(true);
}
+ $builtin = idx($params, 'builtin');
+ if ($builtin) {
+ $this->setBuiltinName($builtin);
+ }
+
$mime_type = idx($params, 'mime-type');
if ($mime_type) {
$this->setMimeType($mime_type);
@@ -1142,6 +1164,9 @@
public function getPolicy($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
+ if ($this->isBuiltin()) {
+ return PhabricatorPolicies::getMostOpenPolicy();
+ }
return $this->getViewPolicy();
case PhabricatorPolicyCapability::CAN_EDIT:
return PhabricatorPolicies::POLICY_NOONE;

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 5:59 PM (19 h, 54 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6915078
Default Alt Text
D11917.diff (2 KB)

Event Timeline