Various code cleanup.

This commit is contained in:
James Cole
2018-08-04 17:30:06 +02:00
parent 5af026674f
commit f0d3ca5d53
88 changed files with 552 additions and 311 deletions

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\ExportJob;
use Carbon\Carbon;
use Exception;
use FireflyIII\Models\ExportJob;
use FireflyIII\User;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
@@ -54,11 +55,10 @@ class ExportJobRepository implements ExportJobRepositoryInterface
/**
* @return bool
* @throws \Exception
*/
public function cleanup(): bool
{
$dayAgo = Carbon::create()->subDay();
$dayAgo = Carbon::now()->subDay();
$set = ExportJob::where('created_at', '<', $dayAgo->format('Y-m-d H:i:s'))
->whereIn('status', ['never_started', 'export_status_finished', 'export_downloaded'])
->get();
@@ -74,7 +74,11 @@ class ExportJobRepository implements ExportJobRepositoryInterface
unlink(storage_path('export') . DIRECTORY_SEPARATOR . $file);
}
}
$entry->delete();
try {
$entry->delete();
} catch (Exception $e) {
Log::debug(sprintf('Could not delete object: %s', $e->getMessage()));
}
}
return true;
@@ -142,8 +146,8 @@ class ExportJobRepository implements ExportJobRepositoryInterface
*/
public function getContent(ExportJob $job): string
{
$disk = Storage::disk('export');
$file = $job->key . '.zip';
$disk = Storage::disk('export');
$file = $job->key . '.zip';
try {
$content = $disk->get($file);

View File

@@ -375,7 +375,7 @@ class RecurringRepository implements RecurringRepositoryInterface
}
if ('yearly' === $repetition->repetition_type) {
//
$today = Carbon::create()->endOfYear();
$today = Carbon::now()->endOfYear();
$repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment);
$diffInYears = $today->diffInYears($repDate);
$repDate->addYears($diffInYears); // technically not necessary.