Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15422319
D17620.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D17620.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 23, 7:14 AM (2 d, 5 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7718078
Default Alt Text
D17620.diff (1 KB)
Attached To
Mode
D17620: Upgrade File content hashing to SHA256
Attached
Detach File
Event Timeline
Log In to Comment