@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 100 lines 2.5 kB view raw
1<?php 2 3final class PhabricatorFileChunk extends PhabricatorFileDAO 4 implements 5 PhabricatorPolicyInterface, 6 PhabricatorDestructibleInterface { 7 8 protected $chunkHandle; 9 protected $byteStart; 10 protected $byteEnd; 11 protected $dataFilePHID; 12 13 private $dataFile = self::ATTACHABLE; 14 15 protected function getConfiguration() { 16 return array( 17 self::CONFIG_TIMESTAMPS => false, 18 self::CONFIG_COLUMN_SCHEMA => array( 19 'chunkHandle' => 'bytes12', 20 'byteStart' => 'uint64', 21 'byteEnd' => 'uint64', 22 'dataFilePHID' => 'phid?', 23 ), 24 self::CONFIG_KEY_SCHEMA => array( 25 'key_file' => array( 26 'columns' => array('chunkHandle', 'byteStart', 'byteEnd'), 27 ), 28 'key_data' => array( 29 'columns' => array('dataFilePHID'), 30 ), 31 ), 32 ) + parent::getConfiguration(); 33 } 34 35 public static function newChunkHandle() { 36 $seed = Filesystem::readRandomBytes(64); 37 return PhabricatorHash::digestForIndex($seed); 38 } 39 40 public static function initializeNewChunk($handle, $start, $end) { 41 return id(new PhabricatorFileChunk()) 42 ->setChunkHandle($handle) 43 ->setByteStart($start) 44 ->setByteEnd($end); 45 } 46 47 public function attachDataFile(?PhabricatorFile $file = null) { 48 $this->dataFile = $file; 49 return $this; 50 } 51 52 public function getDataFile() { 53 return $this->assertAttached($this->dataFile); 54 } 55 56 57/* -( PhabricatorPolicyInterface )----------------------------------------- */ 58 59 60 public function getCapabilities() { 61 return array( 62 PhabricatorPolicyCapability::CAN_VIEW, 63 ); 64 } 65 66 67 public function getPolicy($capability) { 68 // These objects are low-level and only accessed through the storage 69 // engine, so policies are mostly just in place to let us use the common 70 // query infrastructure. 71 return PhabricatorPolicies::getMostOpenPolicy(); 72 } 73 74 75 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 76 return false; 77 } 78 79 80/* -( PhabricatorDestructibleInterface )----------------------------------- */ 81 82 83 public function destroyObjectPermanently( 84 PhabricatorDestructionEngine $engine) { 85 86 $data_phid = $this->getDataFilePHID(); 87 if ($data_phid) { 88 $data_file = id(new PhabricatorFileQuery()) 89 ->setViewer($engine->getViewer()) 90 ->withPHIDs(array($data_phid)) 91 ->executeOne(); 92 if ($data_file) { 93 $engine->destroyObject($data_file); 94 } 95 } 96 97 $this->delete(); 98 } 99 100}