From 06bfd58b2c05095945d3307bdf87211d1d48dbd3 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 25 Apr 2016 14:36:53 +0200 Subject: [PATCH 1/2] error out if a local storage isn't setup correctly --- lib/private/files/storage/local.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index b0918c82f98..42b7ff0d15c 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -39,6 +39,9 @@ class Local extends \OC\Files\Storage\Common { protected $datadir; public function __construct($arguments) { + if (!isset($arguments['datadir']) || !is_string($arguments['datadir'])) { + throw new \InvalidArgumentException('No data directory set for local storage'); + } $this->datadir = $arguments['datadir']; if (substr($this->datadir, -1) !== '/') { $this->datadir .= '/'; From 884c8215f800e4753e71a03df26f26459f480964 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 26 Apr 2016 16:08:52 +0200 Subject: [PATCH 2/2] add tests --- tests/lib/files/storage/local.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/lib/files/storage/local.php b/tests/lib/files/storage/local.php index 2583863b554..4cc6c6a842c 100644 --- a/tests/lib/files/storage/local.php +++ b/tests/lib/files/storage/local.php @@ -70,5 +70,19 @@ class Local extends Storage { $etag2 = $this->instance->getETag('test.txt'); $this->assertNotEquals($etag1, $etag2); } + + /** + * @expectedException \InvalidArgumentException + */ + public function testInvalidArgumentsEmptyArray() { + new \OC\Files\Storage\Local([]); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testInvalidArgumentsNoArray() { + new \OC\Files\Storage\Local(null); + } }