Page MenuHomePhabricator

D17620.id.diff
No OneTemporary

D17620.id.diff

diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php
--- a/src/applications/files/storage/PhabricatorFile.php
+++ b/src/applications/files/storage/PhabricatorFile.php
@@ -94,7 +94,7 @@
'storageHandle' => 'text255',
'authorPHID' => 'phid?',
'secretKey' => 'bytes20?',
- 'contentHash' => 'bytes40?',
+ 'contentHash' => 'bytes64?',
'ttl' => 'epoch?',
'isExplicitUpload' => 'bool?',
'mailKey' => 'bytes20',
@@ -718,7 +718,17 @@
}
public static function hashFileContent($data) {
- return null;
+ // 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 $hash;
}
public function loadFileData() {

File Metadata

Mime Type
text/plain
Expires
Sat, May 18, 12:33 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6276100
Default Alt Text
D17620.id.diff (1 KB)

Event Timeline