Skip to content

Commit 9ce450a

Browse files
committed
base64 all file reading/writing in the child process adapter
1 parent df920be commit 9ce450a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/ChildProcess/Adapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function read($fileDescriptor, $length, $offset)
195195
'length' => $length,
196196
'offset' => $offset,
197197
]))->then(function ($payload) {
198-
return \React\Promise\resolve($payload['chunk']);
198+
return \React\Promise\resolve(base64_decode($payload['chunk']));
199199
});
200200
}
201201

@@ -209,7 +209,7 @@ public function read($fileDescriptor, $length, $offset)
209209
public function write($fileDescriptor, $data, $length, $offset)
210210
{
211211
return $this->fileDescriptors[$fileDescriptor]->rpc(Factory::rpc('write', [
212-
'chunk' => $data,
212+
'chunk' => base64_encode($data),
213213
'length' => $length,
214214
'offset' => $offset,
215215
]));

src/WoolTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function read(array $payload)
172172
{
173173
fseek($this->fd, $payload['offset']);
174174
return \React\Promise\resolve([
175-
'chunk' => fread($this->fd, $payload['length']),
175+
'chunk' => base64_encode(fread($this->fd, $payload['length'])),
176176
]);
177177
}
178178

@@ -184,7 +184,7 @@ public function write(array $payload)
184184
{
185185
fseek($this->fd, $payload['offset']);
186186
return \React\Promise\resolve([
187-
'written' => fwrite($this->fd, $payload['chunk'], $payload['length']),
187+
'written' => fwrite($this->fd, base64_decode($payload['chunk']), $payload['length']),
188188
]);
189189
}
190190

0 commit comments

Comments
 (0)