mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Check the directory, not the file.
This commit is contained in:
parent
dc808fa807
commit
d121aad28f
@ -88,7 +88,7 @@ class MailError extends Job implements ShouldQueue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} catch (\Exception|TransportException $e) { // @phpstan-ignore-line
|
} catch (\Exception | TransportException $e) { // @phpstan-ignore-line
|
||||||
$message = $e->getMessage();
|
$message = $e->getMessage();
|
||||||
if (str_contains($message, 'Bcc')) {
|
if (str_contains($message, 'Bcc')) {
|
||||||
app('log')->warning('[Bcc] Could not email or log the error. Please validate your email settings, use the .env.example file as a guide.');
|
app('log')->warning('[Bcc] Could not email or log the error. Please validate your email settings, use the .env.example file as a guide.');
|
||||||
@ -109,19 +109,23 @@ class MailError extends Job implements ShouldQueue
|
|||||||
private function reachedLimit(): bool
|
private function reachedLimit(): bool
|
||||||
{
|
{
|
||||||
Log::debug('reachedLimit()');
|
Log::debug('reachedLimit()');
|
||||||
$types = [
|
$types = [
|
||||||
'5m' => ['limit' => 5, 'reset' => 5 * 60],
|
'5m' => ['limit' => 5, 'reset' => 5 * 60],
|
||||||
'1h' => ['limit' => 15, 'reset' => 60 * 60],
|
'1h' => ['limit' => 15, 'reset' => 60 * 60],
|
||||||
'24h' => ['limit' => 15, 'reset' => 24 * 60 * 60],
|
'24h' => ['limit' => 15, 'reset' => 24 * 60 * 60],
|
||||||
];
|
];
|
||||||
$file = storage_path('framework/cache/error-count.json');
|
$file = storage_path('framework/cache/error-count.json');
|
||||||
$limits = [];
|
$directory = storage_path('framework/cache');
|
||||||
if (!is_writable($file)) {
|
$limits = [];
|
||||||
Log::error(sprintf('MailError: cannot write to "%s", cannot rate limit errors!', $file));
|
|
||||||
|
if (!is_writable($directory)) {
|
||||||
|
Log::error(sprintf('MailError: cannot write to "%s", cannot rate limit errors!', $directory));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($file)) {
|
if (!file_exists($file)) {
|
||||||
|
|
||||||
Log::debug(sprintf('Wrote new file in "%s"', $file));
|
Log::debug(sprintf('Wrote new file in "%s"', $file));
|
||||||
file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));
|
file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user