mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Various code cleanup.
This commit is contained in:
@@ -24,8 +24,8 @@ namespace FireflyIII\Repositories\Account;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Note;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
@@ -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));
|
||||
|
@@ -25,6 +25,7 @@ namespace FireflyIII\Repositories\ExportJob;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\ExportJob;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Illuminate\Support\Str;
|
||||
use Log;
|
||||
use Storage;
|
||||
@@ -120,6 +121,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
*
|
||||
* @return ExportJob|null
|
||||
*/
|
||||
public function findByKey(string $key): ?ExportJob
|
||||
@@ -137,14 +139,19 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
||||
* @param ExportJob $job
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function getContent(ExportJob $job): string
|
||||
{
|
||||
$disk = Storage::disk('export');
|
||||
$file = $job->key . '.zip';
|
||||
$disk = Storage::disk('export');
|
||||
$file = $job->key . '.zip';
|
||||
$content = '';
|
||||
try {
|
||||
$content = $disk->get($file);
|
||||
} catch (FileNotFoundException $e) {
|
||||
Log::warning(sprintf('File not found: %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
return $disk->get($file);
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -25,7 +25,7 @@ namespace FireflyIII\Repositories\Journal;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Note;
|
||||
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionJournalMeta;
|
||||
|
Reference in New Issue
Block a user