Various code cleanup.

This commit is contained in:
James Cole
2018-07-26 06:10:17 +02:00
parent e8c9554dd6
commit 6bcfea1de4
37 changed files with 351 additions and 185 deletions

View File

@@ -31,6 +31,7 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Note;
use FireflyIII\User;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Collection;
use Log;
use Storage;
@@ -81,6 +82,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
/**
* @param int $attachmentId
*
* @return Attachment|null
*/
public function findWithoutUser(int $attachmentId): ?Attachment
@@ -119,8 +121,6 @@ class AttachmentRepository implements AttachmentRepositoryInterface
* @param Attachment $attachment
*
* @return string
*
* @throws \Illuminate\Contracts\Encryption\DecryptException
*/
public function getContent(Attachment $attachment): string
{
@@ -130,7 +130,12 @@ class AttachmentRepository implements AttachmentRepositoryInterface
$content = '';
if ($disk->exists($file)) {
$content = Crypt::decrypt($disk->get($file));
try {
$content = Crypt::decrypt($disk->get($file));
} catch (FileNotFoundException $e) {
Log::debug(sprintf('File not found: %e', $e->getMessage()));
$content = false;
}
}
if (\is_bool($content)) {
Log::error(sprintf('Attachment #%d may be corrupted: the content could not be decrypted.', $attachment->id));