Merge pull request #24246 from owncloud/local-invalid

error out if a local storage isn't setup correctly
This commit is contained in:
Lukas Reschke 2016-04-26 20:57:56 +02:00
commit ddbebe91f0
2 changed files with 17 additions and 0 deletions

View File

@ -39,6 +39,9 @@ class Local extends \OC\Files\Storage\Common {
protected $datadir; protected $datadir;
public function __construct($arguments) { 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']; $this->datadir = $arguments['datadir'];
if (substr($this->datadir, -1) !== '/') { if (substr($this->datadir, -1) !== '/') {
$this->datadir .= '/'; $this->datadir .= '/';

View File

@ -70,5 +70,19 @@ class Local extends Storage {
$etag2 = $this->instance->getETag('test.txt'); $etag2 = $this->instance->getETag('test.txt');
$this->assertNotEquals($etag1, $etag2); $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);
}
} }