summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-08-29 14:36:00 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2014-10-20 11:28:36 +0200
commit9b0f0df7f52d16e71d40834035dd840ad4fa86b0 (patch)
treee850cf5a0898a5e055fc285c83b10a42d5e29d0c
parent87da62072b6df177bceb0c78c350458e0df86d0a (diff)
downloadnextcloud-server-9b0f0df7f52d16e71d40834035dd840ad4fa86b0.tar.gz
nextcloud-server-9b0f0df7f52d16e71d40834035dd840ad4fa86b0.zip
make skeleton compatible with objectstore
suspend encryption proxy when copying skeleton
-rw-r--r--apps/files_sharing/tests/base.php4
-rw-r--r--lib/private/files/objectstore/homeobjectstorestorage.php6
-rw-r--r--lib/private/server.php15
-rwxr-xr-xlib/private/util.php46
4 files changed, 42 insertions, 29 deletions
diff --git a/apps/files_sharing/tests/base.php b/apps/files_sharing/tests/base.php
index 738ba3493ba..84de6006fdb 100644
--- a/apps/files_sharing/tests/base.php
+++ b/apps/files_sharing/tests/base.php
@@ -126,9 +126,9 @@ abstract class Test_Files_Sharing_Base extends \PHPUnit_Framework_TestCase {
}
\OC_Util::tearDownFS();
- \OC_User::setUserId('');
+ \OC::$server->getUserSession()->setUser(null);
\OC\Files\Filesystem::tearDown();
- \OC_User::setUserId($user);
+ \OC::$server->getUserSession()->login($user, $password);
\OC_Util::setupFS($user);
}
diff --git a/lib/private/files/objectstore/homeobjectstorestorage.php b/lib/private/files/objectstore/homeobjectstorestorage.php
index 947fc496b20..14fc604a7f0 100644
--- a/lib/private/files/objectstore/homeobjectstorestorage.php
+++ b/lib/private/files/objectstore/homeobjectstorestorage.php
@@ -34,12 +34,6 @@ class HomeObjectStoreStorage extends ObjectStoreStorage implements \OCP\Files\IH
}
$this->user = $params['user'];
parent::__construct($params);
-
-
- //initialize cache with root directory in cache
- if ( ! $this->is_dir('files') ) {
- $this->mkdir('files');
- }
}
public function getId () {
diff --git a/lib/private/server.php b/lib/private/server.php
index ff34cfdccb6..d2728d2b6ef 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -291,6 +291,8 @@ class Server extends SimpleContainer implements IServerContainer {
return null;
}
$userId = $user->getUID();
+ } else {
+ $user = $this->getUserManager()->get($userId);
}
$dir = '/' . $userId;
$root = $this->getRootFolder();
@@ -305,6 +307,19 @@ class Server extends SimpleContainer implements IServerContainer {
$dir = '/files';
if (!$folder->nodeExists($dir)) {
$folder = $folder->newFolder($dir);
+
+ if (\OCP\App::isEnabled('files_encryption')) {
+ // disable encryption proxy to prevent recursive calls
+ $proxyStatus = \OC_FileProxy::$enabled;
+ \OC_FileProxy::$enabled = false;
+ }
+
+ \OC_Util::copySkeleton($user, $folder);
+
+ if (\OCP\App::isEnabled('files_encryption')) {
+ // re-enable proxy - our work is done
+ \OC_FileProxy::$enabled = $proxyStatus;
+ }
} else {
$folder = $folder->get($dir);
}
diff --git a/lib/private/util.php b/lib/private/util.php
index c0a68c56223..d6515872c5a 100755
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -115,16 +115,6 @@ class OC_Util {
return $storage;
});
- // copy skeleton for local storage only
- if (!isset($objectStore)) {
- $userRoot = OC_User::getHome($user);
- $userDirectory = $userRoot . '/files';
- if (!is_dir($userDirectory)) {
- mkdir($userDirectory, 0755, true);
- OC_Util::copySkeleton($userDirectory);
- }
- }
-
$userDir = '/' . $user . '/files';
//jail the user into his "home" directory
@@ -133,6 +123,9 @@ class OC_Util {
$fileOperationProxy = new OC_FileProxy_FileOperations();
OC_FileProxy::register($fileOperationProxy);
+ //trigger creation of user home and /files folder
+ \OC::$server->getUserFolder($user);
+
OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $userDir));
}
return true;
@@ -208,33 +201,44 @@ class OC_Util {
}
/**
- * copies the user skeleton files into the fresh user home files
+ * copies the skeleton to the users /files
*
- * @param string $userDirectory
+ * @param \OC\User\User $user
+ * @param \OCP\Files\Folder $userDirectory
*/
- public static function copySkeleton($userDirectory) {
- $skeletonDirectory = OC_Config::getValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton');
+ public static function copySkeleton(\OC\User\User $user, \OCP\Files\Folder $userDirectory) {
+
+ $skeletonDirectory = \OCP\Config::getSystemValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton');
+
if (!empty($skeletonDirectory)) {
- OC_Util::copyr($skeletonDirectory, $userDirectory);
+ \OCP\Util::writeLog(
+ 'files_skeleton',
+ 'copying skeleton for '.$user->getUID().' from '.$skeletonDirectory.' to '.$userDirectory->getFullPath('/'),
+ \OCP\Util::DEBUG
+ );
+ self::copyr($skeletonDirectory, $userDirectory);
+ // update the file cache
+ $userDirectory->getStorage()->getScanner()->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE);
}
}
/**
- * copies a directory recursively
+ * copies a directory recursively by using streams
*
* @param string $source
- * @param string $target
+ * @param \OCP\Files\Folder $target
* @return void
*/
- public static function copyr($source, $target) {
+ public static function copyr($source, \OCP\Files\Folder $target) {
$dir = opendir($source);
- @mkdir($target);
while (false !== ($file = readdir($dir))) {
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
if (is_dir($source . '/' . $file)) {
- OC_Util::copyr($source . '/' . $file, $target . '/' . $file);
+ $child = $target->newFolder($file);
+ self::copyr($source . '/' . $file, $child);
} else {
- copy($source . '/' . $file, $target . '/' . $file);
+ $child = $target->newFile($file);
+ stream_copy_to_stream(fopen($source . '/' . $file,'r'), $child->fopen('w'));
}
}
}