Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15469797
D7849.id17763.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D7849.id17763.diff
View Options
Index: src/applications/differential/controller/DifferentialRevisionViewController.php
===================================================================
--- src/applications/differential/controller/DifferentialRevisionViewController.php
+++ src/applications/differential/controller/DifferentialRevisionViewController.php
@@ -70,6 +70,7 @@
if ($request->getExists('download')) {
return $this->buildRawDiffResponse(
+ $revision,
$changesets,
$vs_changesets,
$vs_map,
@@ -850,6 +851,7 @@
* @return @{class:AphrontRedirectResponse}
*/
private function buildRawDiffResponse(
+ DifferentialRevision $revision,
array $changesets,
array $vs_changesets,
array $vs_map,
@@ -910,8 +912,16 @@
$raw_diff,
array(
'name' => $file_name,
+ 'ttl' => (60 * 60 * 24),
+ 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
));
+ $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
+ $file->attachToObject(
+ $this->getRequest()->getUser(),
+ $revision->getPHID());
+ unset($unguarded);
+
return id(new AphrontRedirectResponse())->setURI($file->getBestURI());
}
Index: src/applications/diffusion/controller/DiffusionBrowseFileController.php
===================================================================
--- src/applications/diffusion/controller/DiffusionBrowseFileController.php
+++ src/applications/diffusion/controller/DiffusionBrowseFileController.php
@@ -810,12 +810,21 @@
}
private function loadFileForData($path, $data) {
- return PhabricatorFile::buildFromFileDataOrHash(
+ $file = PhabricatorFile::buildFromFileDataOrHash(
$data,
array(
'name' => basename($path),
'ttl' => time() + 60 * 60 * 24,
+ 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
));
+
+ $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
+ $file->attachToObject(
+ $this->getRequest()->getUser(),
+ $this->getDiffusionRequest()->getRepository()->getPHID());
+ unset($unguarded);
+
+ return $file;
}
private function buildRawResponse($path, $data) {
Index: src/applications/diffusion/controller/DiffusionCommitController.php
===================================================================
--- src/applications/diffusion/controller/DiffusionCommitController.php
+++ src/applications/diffusion/controller/DiffusionCommitController.php
@@ -1049,8 +1049,16 @@
$raw_diff,
array(
'name' => $drequest->getCommit().'.diff',
+ 'ttl' => (60 * 60 * 24),
+ 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
));
+ $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
+ $file->attachToObject(
+ $this->getRequest()->getUser(),
+ $drequest->getRepository()->getPHID());
+ unset($unguarded);
+
return id(new AphrontRedirectResponse())->setURI($file->getBestURI());
}
Index: src/applications/files/controller/PhabricatorFileInfoController.php
===================================================================
--- src/applications/files/controller/PhabricatorFileInfoController.php
+++ src/applications/files/controller/PhabricatorFileInfoController.php
@@ -33,6 +33,8 @@
$this->loadHandles($handle_phids);
$header = id(new PHUIHeaderView())
+ ->setUser($user)
+ ->setPolicyObject($file)
->setHeader($file->getName());
$ttl = $file->getTTL();
Index: src/applications/files/storage/PhabricatorFile.php
===================================================================
--- src/applications/files/storage/PhabricatorFile.php
+++ src/applications/files/storage/PhabricatorFile.php
@@ -175,13 +175,17 @@
$file_ttl = idx($params, 'ttl');
$authorPHID = idx($params, 'authorPHID');
- $new_file = new PhabricatorFile();
+ $new_file = new PhabricatorFile();
$new_file->setName($file_name);
$new_file->setByteSize($copy_of_byteSize);
$new_file->setAuthorPHID($authorPHID);
$new_file->setTtl($file_ttl);
+ if (idx($params, 'viewPolicy')) {
+ $new_file->setViewPolicy($params['viewPolicy']);
+ }
+
$new_file->setContentHash($hash);
$new_file->setStorageEngine($copy_of_storage_engine);
$new_file->setStorageHandle($copy_of_storage_handle);
@@ -262,6 +266,10 @@
$file->setTtl($file_ttl);
$file->setContentHash(self::hashFileContent($data));
+ if (idx($params, 'viewPolicy')) {
+ $file->setViewPolicy($params['viewPolicy']);
+ }
+
$file->setStorageEngine($engine_identifier);
$file->setStorageHandle($data_handle);
@@ -877,8 +885,12 @@
}
public function getPolicy($capability) {
- // TODO: Implement proper per-object policies.
- return PhabricatorPolicies::POLICY_USER;
+ switch ($capability) {
+ case PhabricatorPolicyCapability::CAN_VIEW:
+ return $this->getViewPolicy();
+ case PhabricatorPolicyCapability::CAN_EDIT:
+ return PhabricatorPolicies::POLICY_NOONE;
+ }
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 5, 4:35 PM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7710663
Default Alt Text
D7849.id17763.diff (5 KB)
Attached To
Mode
D7849: Bind patches, file content and raw diffs bind policies to their originating objects
Attached
Detach File
Event Timeline
Log In to Comment