Skip to content

Commit e9e3110

Browse files
committed
Extract errors coming from the child process adapter
1 parent 16ed950 commit e9e3110

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/ChildProcess/Adapter.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22

33
namespace React\Filesystem\ChildProcess;
44

5+
use Exception;
56
use React\EventLoop\LoopInterface;
67
use React\Filesystem\AdapterInterface;
78
use React\Filesystem\CallInvokerInterface;
8-
use React\Filesystem\Node\NodeInterface;
9-
use React\Filesystem\Stream\StreamFactory;
109
use React\Filesystem\FilesystemInterface;
1110
use React\Filesystem\MappedTypeDetector;
1211
use React\Filesystem\ModeTypeDetector;
12+
use React\Filesystem\Node\NodeInterface;
1313
use React\Filesystem\ObjectStream;
1414
use React\Filesystem\OpenFileLimiter;
15+
use React\Filesystem\PermissionFlagResolver;
16+
use React\Filesystem\Stream\StreamFactory;
1517
use React\Filesystem\TypeDetectorInterface;
1618
use React\Promise\FulfilledPromise;
1719
use React\Promise\PromiseInterface;
@@ -69,6 +71,11 @@ class Adapter implements AdapterInterface
6971
'lsFlags' => SCANDIR_SORT_NONE,
7072
];
7173

74+
/**
75+
* @var PermissionFlagResolver
76+
*/
77+
private $permissionFlagResolver;
78+
7279
/**
7380
* Adapter constructor.
7481
* @param LoopInterface $loop
@@ -80,6 +87,7 @@ public function __construct(LoopInterface $loop, array $options = [])
8087

8188
$this->invoker = \React\Filesystem\getInvoker($this, $options, 'invoker', 'React\Filesystem\InstantInvoker');
8289
$this->openFileLimiter = new OpenFileLimiter(\React\Filesystem\getOpenFileLimit($options));
90+
$this->permissionFlagResolver = new PermissionFlagResolver();
8391

8492
$this->setUpPool($options);
8593

@@ -148,6 +156,8 @@ public function callFilesystem($function, $args, $errorResultCode = -1)
148156
{
149157
return $this->pool->rpc(Factory::rpc($function, $args))->then(function (Payload $payload) {
150158
return \React\Promise\resolve($payload->getPayload());
159+
}, function (Payload $payload) {
160+
return \React\Promise\reject(new Exception($payload->getPayload()['error']['error']['message']));
151161
});
152162
}
153163

@@ -160,7 +170,7 @@ public function mkdir($path, $mode = self::CREATION_MODE)
160170
{
161171
return $this->invoker->invokeCall('mkdir', [
162172
'path' => $path,
163-
'mode' => $mode,
173+
'mode' => decoct($this->permissionFlagResolver->resolve($mode)),
164174
]);
165175
}
166176

@@ -279,6 +289,7 @@ public function touch($path, $mode = self::CREATION_MODE)
279289
{
280290
return $this->invoker->invokeCall('touch', [
281291
'path' => $path,
292+
'mode' => decoct($this->permissionFlagResolver->resolve($mode)),
282293
]);
283294
}
284295

0 commit comments

Comments
 (0)