diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2015-10-02 09:59:58 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2015-10-08 14:54:21 +0200 |
commit | 89a63ec74bb8f786a0e3a8df133abe84ef493489 (patch) | |
tree | 040e0d16c71e36d386b8c586cc1ffee618d2d0ae /lib | |
parent | 17ffa4a244fef9d6cac453f4de9cbeb2b202c90d (diff) | |
download | nextcloud-server-89a63ec74bb8f786a0e3a8df133abe84ef493489.tar.gz nextcloud-server-89a63ec74bb8f786a0e3a8df133abe84ef493489.zip |
make mkdir recursive, add phpdoc to api
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/files/objectstore/objectstorestorage.php | 39 | ||||
-rw-r--r-- | lib/public/files/storage.php | 1 |
2 files changed, 22 insertions, 18 deletions
diff --git a/lib/private/files/objectstore/objectstorestorage.php b/lib/private/files/objectstore/objectstorestorage.php index a85553186ae..40d52feb893 100644 --- a/lib/private/files/objectstore/objectstorestorage.php +++ b/lib/private/files/objectstore/objectstorestorage.php @@ -62,41 +62,44 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { public function mkdir($path) { $path = $this->normalizePath($path); - if ($this->is_dir($path)) { + if ($this->file_exists($path)) { return false; } - $dirName = $this->normalizePath(dirname($path)); - $parentExists = $this->is_dir($dirName); - $mTime = time(); - - $data = array( + $data = [ 'mimetype' => 'httpd/unix-directory', 'size' => 0, 'mtime' => $mTime, 'storage_mtime' => $mTime, 'permissions' => \OCP\Constants::PERMISSION_ALL, - ); - - if ($dirName === '' && !$parentExists) { + ]; + if ($path === '') { //create root on the fly $data['etag'] = $this->getETag(''); $this->getCache()->put('', $data); - $parentExists = true; - - // we are done when the root folder was meant to be created - if ($dirName === $path) { - return true; + return true; + } else { + // if parent does not exist, create it + $parent = $this->normalizePath(dirname($path)); + $parentType = $this->filetype($parent); + if ($parentType === false) { + if (!$this->mkdir($parent)) { + // something went wrong + return false; + } + } else if ($parentType === 'file') { + // parent is a file + return false; } - } - - if ($parentExists) { + // finally create the new dir + $mTime = time(); // update mtime + $data['mtime'] = $mTime; + $data['storage_mtime'] = $mTime; $data['etag'] = $this->getETag($path); $this->getCache()->put($path, $data); return true; } - return false; } /** diff --git a/lib/public/files/storage.php b/lib/public/files/storage.php index 1cf8676c99d..7931a683ae1 100644 --- a/lib/public/files/storage.php +++ b/lib/public/files/storage.php @@ -62,6 +62,7 @@ interface Storage { /** * see http://php.net/manual/en/function.mkdir.php + * implementations need to implement a recursive mkdir * * @param string $path * @return bool |