Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/storage/PhabricatorFile.php
Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | return array( | ||||
'name' => 'text255?', | 'name' => 'text255?', | ||||
'mimeType' => 'text255?', | 'mimeType' => 'text255?', | ||||
'byteSize' => 'uint64', | 'byteSize' => 'uint64', | ||||
'storageEngine' => 'text32', | 'storageEngine' => 'text32', | ||||
'storageFormat' => 'text32', | 'storageFormat' => 'text32', | ||||
'storageHandle' => 'text255', | 'storageHandle' => 'text255', | ||||
'authorPHID' => 'phid?', | 'authorPHID' => 'phid?', | ||||
'secretKey' => 'bytes20?', | 'secretKey' => 'bytes20?', | ||||
'contentHash' => 'bytes40?', | 'contentHash' => 'bytes64?', | ||||
'ttl' => 'epoch?', | 'ttl' => 'epoch?', | ||||
'isExplicitUpload' => 'bool?', | 'isExplicitUpload' => 'bool?', | ||||
'mailKey' => 'bytes20', | 'mailKey' => 'bytes20', | ||||
'isPartial' => 'bool', | 'isPartial' => 'bool', | ||||
'builtinKey' => 'text64?', | 'builtinKey' => 'text64?', | ||||
), | ), | ||||
self::CONFIG_KEY_SCHEMA => array( | self::CONFIG_KEY_SCHEMA => array( | ||||
'key_phid' => null, | 'key_phid' => null, | ||||
▲ Show 20 Lines • Show All 607 Lines • ▼ Show 20 Lines | if (!$usage) { | ||||
// In the worst case, we're leaving some data stranded in a storage | // In the worst case, we're leaving some data stranded in a storage | ||||
// engine, which is not a big deal. | // engine, which is not a big deal. | ||||
phlog($ex); | phlog($ex); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public static function hashFileContent($data) { | public static function hashFileContent($data) { | ||||
// NOTE: Hashing can fail if the algorithm isn't available in the current | |||||
// build of PHP. It's fine if we're unable to generate a content hash: | |||||
// it just means we'll store extra data when users upload duplicate files | |||||
// instead of being able to deduplicate it. | |||||
$hash = hash('sha256', $data, $raw_output = false); | |||||
if ($hash === false) { | |||||
return null; | return null; | ||||
} | } | ||||
return $hash; | |||||
} | |||||
public function loadFileData() { | public function loadFileData() { | ||||
$iterator = $this->getFileDataIterator(); | $iterator = $this->getFileDataIterator(); | ||||
return $this->loadDataFromIterator($iterator); | return $this->loadDataFromIterator($iterator); | ||||
} | } | ||||
/** | /** | ||||
* Return an iterable which emits file content bytes. | * Return an iterable which emits file content bytes. | ||||
▲ Show 20 Lines • Show All 799 Lines • Show Last 20 Lines |