public function save()
 {
     if (!$this->getMailKey()) {
         $this->setMailKey(Filesystem::readRandomCharacters(20));
     }
     return parent::save();
 }
 protected function didWriteData()
 {
     $size = self::CHUNK_SIZE;
     $length = strlen($this->fullData);
     if ($length > $size) {
         $conn = $this->establishConnection('w');
         for ($offset = $size; $offset < $length; $offset += $size) {
             queryfx($conn, 'UPDATE %T SET data = CONCAT(data, %s) WHERE %C = %d', $this->getTableName(), substr($this->fullData, $offset, $size), $this->getIDKeyForUse(), $this->getID());
         }
         $this->saveTransaction();
     }
     parent::didWriteData();
 }
 protected function getConfiguration()
 {
     return array(self::CONFIG_TIMESTAMPS => false, self::CONFIG_COLUMN_SCHEMA => array('chunkHandle' => 'bytes12', 'byteStart' => 'uint64', 'byteEnd' => 'uint64', 'dataFilePHID' => 'phid?'), self::CONFIG_KEY_SCHEMA => array('key_file' => array('columns' => array('chunkHandle', 'byteStart', 'byteEnd')), 'key_data' => array('columns' => array('dataFilePHID')))) + parent::getConfiguration();
 }
Esempio n. 4
0
 public function save()
 {
     if (!$this->getSecretKey()) {
         $this->setSecretKey($this->generateSecretKey());
     }
     return parent::save();
 }
 public function getConfiguration()
 {
     return array(self::CONFIG_TIMESTAMPS => false) + parent::getConfiguration();
 }
 public function save()
 {
     $hash = PhabricatorHash::digestForIndex($this->getURI());
     $this->setURIIndex($hash);
     return parent::save();
 }
 public function delete()
 {
     // We want to delete all the rows which mark this file as the transformation
     // of some other file (since we're getting rid of it). We also delete all
     // the transformations of this file, so that a user who deletes an image
     // doesn't need to separately hunt down and delete a bunch of thumbnails and
     // resizes of it.
     $outbound_xforms = id(new PhabricatorFileQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withTransforms(array(array('originalPHID' => $this->getPHID(), 'transform' => true)))->execute();
     foreach ($outbound_xforms as $outbound_xform) {
         $outbound_xform->delete();
     }
     $inbound_xforms = id(new PhabricatorTransformedFile())->loadAllWhere('transformedPHID = %s', $this->getPHID());
     $this->openTransaction();
     foreach ($inbound_xforms as $inbound_xform) {
         $inbound_xform->delete();
     }
     $ret = parent::delete();
     $this->saveTransaction();
     $this->deleteFileDataIfUnused($this->instantiateStorageEngine(), $this->getStorageEngine(), $this->getStorageHandle());
     return $ret;
 }
 protected function getConfiguration()
 {
     return array(self::CONFIG_COLUMN_SCHEMA => array('transform' => 'text128'), self::CONFIG_KEY_SCHEMA => array('originalPHID' => array('columns' => array('originalPHID', 'transform'), 'unique' => true), 'transformedPHID' => array('columns' => array('transformedPHID')))) + parent::getConfiguration();
 }
 public function delete()
 {
     $engine = $this->instantiateStorageEngine();
     $ret = parent::delete();
     $engine->deleteFile($this->getStorageHandle());
     return $ret;
 }
 protected function getConfiguration()
 {
     return array(self::CONFIG_BINARY => array('data' => true)) + parent::getConfiguration();
 }