diff options
author | karakayasemi <karakayasemi@itu.edu.tr> | 2016-06-21 17:10:52 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-06-21 17:10:52 +0200 |
commit | c8b7a059b4b8ae9a72d7be36f7e42fefbb130d35 (patch) | |
tree | 86bae8f2c7b7f62e05829c883599bbf3a8984acc /lib | |
parent | cab7106dfb75ac9c59d4cdac132b17a1d2f97534 (diff) | |
download | nextcloud-server-c8b7a059b4b8ae9a72d7be36f7e42fefbb130d35.tar.gz nextcloud-server-c8b7a059b4b8ae9a72d7be36f7e42fefbb130d35.zip |
Fire hooks for mkdir for folder upload
fromTmpFile function, usual mkdir call is only working for file's parent
directory. Does not care upper parent folders. I added a recursive
function that creates parent non-existing folders with usual mkdir.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/View.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index e9daa123470..31549c93cb2 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -998,7 +998,10 @@ class View { // Create the directories if any if (!$this->file_exists($filePath)) { - $this->mkdir($filePath); + $result = $this->createParentDirectories($filePath); + if($result === false) { + return false; + } } $source = fopen($tmpFile, 'r'); @@ -2107,4 +2110,22 @@ class View { } return [$uid, $filename]; } + + /** + * Creates parent non-existing folders + * + * @param string $filePath + * @return bool + */ + private function createParentDirectories($filePath) { + $parentDirectory = dirname($filePath); + while(!$this->file_exists($parentDirectory)) { + $result = $this->createParentDirectories($parentDirectory); + if($result === false) { + return false; + } + } + $this->mkdir($filePath); + return true; + } } |