Skip to content

Commit 2cd198f

Browse files
committed
Merge pull request #102 from hskrasek/master
Update RackspaceAdapter->has() to catch OpenCloud ObjectNotFoundExceptio...
2 parents ee607ae + dfaf088 commit 2cd198f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Adapter/Rackspace.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use League\Flysystem\Util;
66
use OpenCloud\ObjectStore\Resource\Container;
77
use OpenCloud\ObjectStore\Resource\DataObject;
8+
use OpenCloud\ObjectStore\Exception\ObjectNotFoundException;
89
use Guzzle\Http\Exception\ClientErrorResponseException;
910

1011
class Rackspace extends AbstractAdapter
@@ -163,6 +164,8 @@ public function has($path)
163164
$object = $this->getObject($path);
164165
} catch(ClientErrorResponseException $e) {
165166
return false;
167+
} catch(ObjectNotFoundException $e) {
168+
return false;
166169
}
167170

168171
return $this->normalizeObject($object);

tests/RackspaceTests.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ public function testHasFail()
4949
$this->assertFalse($adapter->has('filename.ext'));
5050
}
5151

52+
public function testHasNotFound()
53+
{
54+
$container = $this->getContainerMock();
55+
$container->shouldReceive('getObject')->andThrow('OpenCloud\ObjectStore\Exception\ObjectNotFoundException');
56+
$adapter = new Rackspace($container);
57+
$this->assertFalse($adapter->has('filename.ext'));
58+
}
59+
5260
public function testWrite()
5361
{
5462
$container = $this->getContainerMock();

0 commit comments

Comments
 (0)