Fix saving hash of a deleted file from disk (#4813)

This commit is contained in:
Yuriy Bakhtin 2021-02-01 14:56:50 +03:00 committed by GitHub
parent 2cfe20a920
commit a615a26268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -36,3 +36,4 @@
- Enh #4787: Always enable Space Membership Web Notifications
- Enh #4795: Added support for collapsible form fields
- Enh #4796: Added option to disable PWA/ServiceWorker support
- Fix #4752: Fix saving hash of a deleted file from disk

View File

@ -157,7 +157,12 @@ class File extends FileCompat
*/
public function saveHash()
{
$this->hash_sha1 = sha1_file($this->getStore()->get());
$filePath = $this->getStore()->get();
if (!is_file($filePath)) {
return;
}
$this->hash_sha1 = sha1_file($filePath);
if (!$this->isNewRecord) {
$this->updateAttributes(['hash_sha1' => $this->hash_sha1]);
}