Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/storage/PhabricatorFile.php
| Show First 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | if (!$this->getSecretKey()) { | ||||
| $this->setSecretKey($this->generateSecretKey()); | $this->setSecretKey($this->generateSecretKey()); | ||||
| } | } | ||||
| if (!$this->getMailKey()) { | if (!$this->getMailKey()) { | ||||
| $this->setMailKey(Filesystem::readRandomCharacters(20)); | $this->setMailKey(Filesystem::readRandomCharacters(20)); | ||||
| } | } | ||||
| return parent::save(); | return parent::save(); | ||||
| } | } | ||||
| public function saveAndIndex() { | |||||
| $this->save(); | |||||
| PhabricatorSearchWorker::queueDocumentForIndexing($this->getPHID()); | |||||
| return $this; | |||||
| } | |||||
| public function getMonogram() { | public function getMonogram() { | ||||
| return 'F'.$this->getID(); | return 'F'.$this->getID(); | ||||
| } | } | ||||
| public function scrambleSecret() { | public function scrambleSecret() { | ||||
| return $this->setSecretKey($this->generateSecretKey()); | return $this->setSecretKey($this->generateSecretKey()); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | public static function newFileFromContentHash($hash, array $params) { | ||||
| $new_file->setStorageHandle($copy_of_storage_handle); | $new_file->setStorageHandle($copy_of_storage_handle); | ||||
| $new_file->setStorageFormat($copy_of_storage_format); | $new_file->setStorageFormat($copy_of_storage_format); | ||||
| $new_file->setStorageProperties($copy_of_storage_properties); | $new_file->setStorageProperties($copy_of_storage_properties); | ||||
| $new_file->setMimeType($copy_of_mime_type); | $new_file->setMimeType($copy_of_mime_type); | ||||
| $new_file->copyDimensions($file); | $new_file->copyDimensions($file); | ||||
| $new_file->readPropertiesFromParameters($params); | $new_file->readPropertiesFromParameters($params); | ||||
| $new_file->save(); | $new_file->saveAndIndex(); | ||||
| return $new_file; | return $new_file; | ||||
| } | } | ||||
| public static function newChunkedFile( | public static function newChunkedFile( | ||||
| PhabricatorFileStorageEngine $engine, | PhabricatorFileStorageEngine $engine, | ||||
| $length, | $length, | ||||
| array $params) { | array $params) { | ||||
| ▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | private static function buildFromFileData($data, array $params = array()) { | ||||
| } | } | ||||
| try { | try { | ||||
| $file->updateDimensions(false); | $file->updateDimensions(false); | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| // Do nothing | // Do nothing | ||||
| } | } | ||||
| $file->save(); | $file->saveAndIndex(); | ||||
| return $file; | return $file; | ||||
| } | } | ||||
| public static function newFromFileData($data, array $params = array()) { | public static function newFromFileData($data, array $params = array()) { | ||||
| $hash = self::hashFileContent($data); | $hash = self::hashFileContent($data); | ||||
| if ($hash !== null) { | if ($hash !== null) { | ||||
| ▲ Show 20 Lines • Show All 1,199 Lines • Show Last 20 Lines | |||||