feat(filesystem): introduce FileOwnership and ProcessUser value objects
- Add `FileOwnership` to encapsulate file owner and group information. - Add `ProcessUser` to represent and manage system process user details. - Enhance ownership matching and debugging with structured data objects. - Include new documentation on file ownership handling and permission improvements. - Prepare infrastructure for enriched error handling in filesystem operations.
This commit is contained in:
@@ -115,14 +115,14 @@ final readonly class FileStorage implements Storage, AtomicStorage, AppendableSt
|
||||
}
|
||||
|
||||
if (! is_readable($resolvedPath)) {
|
||||
throw FilePermissionException::read($path, 'File is not readable');
|
||||
throw FilePermissionException::read($path, 'File is not readable', $this->permissions);
|
||||
}
|
||||
|
||||
$content = @file_get_contents($resolvedPath);
|
||||
if ($content === false) {
|
||||
$error = error_get_last();
|
||||
if ($error && str_contains($error['message'], 'Permission denied')) {
|
||||
throw FilePermissionException::read($path, $error['message']);
|
||||
throw FilePermissionException::read($path, $error['message'], $this->permissions);
|
||||
}
|
||||
|
||||
throw new FileReadException($path);
|
||||
@@ -156,24 +156,24 @@ final readonly class FileStorage implements Storage, AtomicStorage, AppendableSt
|
||||
if (! @mkdir($dir, 0777, true) && ! is_dir($dir)) {
|
||||
$error = error_get_last();
|
||||
if ($error && str_contains($error['message'], 'Permission denied')) {
|
||||
throw FilePermissionException::createDirectory($dir, $error['message']);
|
||||
throw FilePermissionException::createDirectory($dir, $error['message'], $this->permissions);
|
||||
}
|
||||
|
||||
throw new DirectoryCreateException($dir);
|
||||
}
|
||||
} elseif (! is_writable($dir)) {
|
||||
throw FilePermissionException::write($path, 'Directory is not writable: ' . $dir);
|
||||
throw FilePermissionException::write($path, 'Directory is not writable: ' . $dir, $this->permissions);
|
||||
}
|
||||
|
||||
// Prüfe File-Permissions wenn Datei bereits existiert
|
||||
if (is_file($resolvedPath) && ! is_writable($resolvedPath)) {
|
||||
throw FilePermissionException::write($path, 'File is not writable');
|
||||
throw FilePermissionException::write($path, 'File is not writable', $this->permissions);
|
||||
}
|
||||
|
||||
if (@file_put_contents($resolvedPath, $content) === false) {
|
||||
$error = error_get_last();
|
||||
if ($error && str_contains($error['message'], 'Permission denied')) {
|
||||
throw FilePermissionException::write($path, $error['message']);
|
||||
throw FilePermissionException::write($path, $error['message'], $this->permissions);
|
||||
}
|
||||
|
||||
throw new FileWriteException($path);
|
||||
@@ -229,7 +229,7 @@ final readonly class FileStorage implements Storage, AtomicStorage, AppendableSt
|
||||
if (! @unlink($resolvedPath)) {
|
||||
$error = error_get_last();
|
||||
if ($error && str_contains($error['message'], 'Permission denied')) {
|
||||
throw FilePermissionException::delete($path, $error['message']);
|
||||
throw FilePermissionException::delete($path, $error['message'], $this->permissions);
|
||||
}
|
||||
|
||||
throw new FileDeleteException($path);
|
||||
@@ -386,13 +386,13 @@ final readonly class FileStorage implements Storage, AtomicStorage, AppendableSt
|
||||
// Prüfe Parent-Directory Permissions
|
||||
$parentDir = dirname($resolvedPath);
|
||||
if (is_dir($parentDir) && ! is_writable($parentDir)) {
|
||||
throw FilePermissionException::createDirectory($path, 'Parent directory is not writable: ' . $parentDir);
|
||||
throw FilePermissionException::createDirectory($path, 'Parent directory is not writable: ' . $parentDir, $this->permissions);
|
||||
}
|
||||
|
||||
if (! @mkdir($resolvedPath, $permissions, $recursive) && ! is_dir($resolvedPath)) {
|
||||
$error = error_get_last();
|
||||
if ($error && str_contains($error['message'], 'Permission denied')) {
|
||||
throw FilePermissionException::createDirectory($path, $error['message']);
|
||||
throw FilePermissionException::createDirectory($path, $error['message'], $this->permissions);
|
||||
}
|
||||
|
||||
throw new DirectoryCreateException($path);
|
||||
|
||||
Reference in New Issue
Block a user