diff --git a/src/Flysystem/Adapter/FedoraAdapter.php b/src/Flysystem/Adapter/FedoraAdapter.php index 6946117b..bd0a0331 100644 --- a/src/Flysystem/Adapter/FedoraAdapter.php +++ b/src/Flysystem/Adapter/FedoraAdapter.php @@ -253,7 +253,8 @@ class FedoraAdapter implements AdapterInterface { $headers = [ 'Content-Type' => $this->mimeTypeGuesser->guess($path), ]; - if ($this->has($path)) { + $heads_response = $this->fedora->getResourceHeaders($path); + if (isset($heads_response) && $heads_response->getStatusCode() == 200) { $fedora_url = $path; $date = new DateTime(); $timestamp = $date->format("D, d M Y H:i:s O"); diff --git a/tests/src/Kernel/FedoraAdapterTest.php b/tests/src/Kernel/FedoraAdapterTest.php index abff8eea..5d17814d 100644 --- a/tests/src/Kernel/FedoraAdapterTest.php +++ b/tests/src/Kernel/FedoraAdapterTest.php @@ -84,6 +84,10 @@ class FedoraAdapterTest extends IslandoraKernelTestBase { protected function createAdapterForWrite() { $fedora_prophecy = $this->prophesize(IFedoraApi::class); + $prophecy = $this->prophesize(Response::class); + $prophecy->getStatusCode()->willReturn(201); + $fedora_prophecy->createVersion('', Argument::any(), NULL, + Argument::any())->willReturn($prophecy->reveal()); $prophecy = $this->prophesize(Response::class); $prophecy->getStatusCode()->willReturn(201); @@ -111,6 +115,9 @@ class FedoraAdapterTest extends IslandoraKernelTestBase { */ protected function createAdapterForWriteFail() { $fedora_prophecy = $this->prophesize(IFedoraApi::class); + $prophecy = $this->prophesize(Response::class); + $prophecy->getStatusCode()->willReturn(500); + $fedora_prophecy->getResourceHeaders('')->willReturn($prophecy->reveal()); $prophecy = $this->prophesize(Response::class); $prophecy->getStatusCode()->willReturn(500); @@ -562,6 +569,14 @@ class FedoraAdapterTest extends IslandoraKernelTestBase { $prophecy->getStatusCode()->willReturn(201); $response = $prophecy->reveal(); + $date = new \DateTime(); + $timestamp = $date->format("D, d M Y H:i:s O"); + $fedora_prophecy->createVersion('', + Argument::any(), NULL, + Argument::any())->willReturn($prophecy->reveal()); + $prophecy = $this->prophesize(Response::class); + $prophecy->getStatusCode()->willReturn(201); + $fedora_prophecy->saveResource(Argument::any(), Argument::any(), Argument::any())->willReturn($response); $prophecy = $this->prophesize(Response::class);