Skip to content

Commit

Permalink
Upgrade amphp/file to version 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mmenozzi committed Oct 6, 2022
1 parent 573b1cf commit 6cb5c67
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"psr/log": "^1.1",
"amphp/socket": "^1.0",
"amphp/http": "^1.1",
"amphp/file": "^0.3",
"amphp/file": "^2.0",
"webmozart/assert": "^1.5",
"symfony/serializer": "^4.3",
"symfony/property-access": "^4.3",
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ private function requestHandler(Request $request): \Generator
$httpMethod = $request->getMethod();
$uri = $request->getUri()->getPath();
$filePath = $this->publicDir . DIRECTORY_SEPARATOR . ltrim($uri, '/');
if ((yield File\exists($filePath)) && (yield File\isfile($filePath))) {
return new Response(Status::OK, [], yield File\get($filePath));
if ((yield File\exists($filePath)) && (yield File\isFile($filePath))) {
return new Response(Status::OK, [], yield File\read($filePath));
}

$dispatcher = $this->getDispatcher($request);
Expand Down
12 changes: 6 additions & 6 deletions tests/DummyFilesystemRepeatProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ public function init(): Promise
public function produce($data = null): Iterator
{
return new Producer(function (callable $emit) {
if (!(yield File\isdir($this->directory))) {
if (!(yield File\mkdir($this->directory)) && !(yield File\isdir($this->directory))) {
if (!(yield File\isDirectory($this->directory))) {
if (!(yield File\createDirectory($this->directory)) && !(yield File\createDirectory($this->directory))) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $this->directory));
}
}
$files = yield File\scandir($this->directory);
$files = yield File\listFiles($this->directory);
foreach ($files as $file) {
$file = $this->directory . DIRECTORY_SEPARATOR . $file;
if (yield File\isdir($file)) {
if (yield File\isDirectory($file)) {
continue;
}
yield $this->longRunningOperation();
yield $emit(new Job(['file' => $file, 'data' => (yield File\get($file))]));
yield \Amp\File\unlink($file);
yield $emit(new Job(['file' => $file, 'data' => (yield File\read($file))]));
yield \Amp\File\deleteFile($file);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions tests/DummyFilesystemWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ public function work(JobInterface $job): Promise
return call(function () use ($job) {
$content = '';
if (yield File\exists($this->filename)) {
$content = yield \Amp\File\get($this->filename);
$content = yield \Amp\File\read($this->filename);
}
if ($this->duration) {
yield delay($this->duration * 1000);
}
//The date() function does not support microseconds, whereas DateTime does.
$now = new \DateTime('now');
$content .= $now->format('U u') . ' - ' . serialize($job->getPayloadData()) . PHP_EOL;
yield File\put($this->filename, $content);
yield File\write($this->filename, $content);
});
}
}
2 changes: 1 addition & 1 deletion tests/KernelTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

namespace Webgriffe\Esb;

use Amp\File\Driver\BlockingDriver;
use Webgriffe\AmpElasticsearch\Client;
use Amp\File\BlockingDriver;
use Amp\Loop;
use Amp\Promise;
use Monolog\Handler\TestHandler;
Expand Down

0 comments on commit 6cb5c67

Please sign in to comment.