Validate directory permissions with a lot of debug logs.

This commit is contained in:
James Cole
2026-02-10 20:26:41 +01:00
parent 2c2ebae8fa
commit c74c8a96b8

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Integrity;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
class ValidatesFilePermissions extends Command
{
@@ -36,7 +37,7 @@ class ValidatesFilePermissions extends Command
*
* @var string
*/
protected $signature = 'integrity:file-permissions';
protected $signature = 'integrity:file-permissions';
/**
* The console command description.
@@ -50,26 +51,38 @@ class ValidatesFilePermissions extends Command
*/
public function handle(): int
{
Log::debug(sprintf('Start of %s', $this->signature));
$directories = [storage_path('upload')];
$errors = false;
/** @var string $directory */
foreach ($directories as $directory) {
Log::debug(sprintf('Processing directory: %s', $directory));
if (!is_dir($directory)) {
$this->friendlyError(sprintf('Directory "%s" cannot found. It is necessary to allow files to be uploaded.', $directory));
$message = sprintf('Directory "%s" cannot found. It is necessary to allow files to be uploaded.', $directory);
Log::error($message);
$this->friendlyError($message);
$errors = true;
continue;
}
Log::debug('It is a directory!');
if (!is_writable($directory)) {
$this->friendlyError(sprintf('Directory "%s" is not writeable. Uploading attachments may fail silently.', $directory));
$message = sprintf('Directory "%s" is not writeable. Uploading attachments may fail silently.', $directory);
$this->friendlyError($message);
Log::error($message);
$errors = true;
}
Log::debug('It is writeable!');
Log::debug(sprintf('Done processing %s', $directory));
}
Log::debug('Done with loop.');
if (false === $errors) {
Log::debug('No errors.');
$this->friendlyInfo('All necessary file paths seem to exist, and are writeable.');
}
Log::debug(sprintf('End of %s', $this->signature));
return self::SUCCESS;
}
}