Skip to content

Commit

Permalink
Cleanup filesystem setup code
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Nov 25, 2014
1 parent 5531882 commit f01e6d7
Show file tree
Hide file tree
Showing 45 changed files with 635 additions and 599 deletions.
2 changes: 1 addition & 1 deletion apps/files/ajax/scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

foreach ($users as $user) {
$eventSource->send('user', $user);
$scanner = new \OC\Files\Utils\Scanner($user, \OC::$server->getDatabaseConnection());
$scanner = new \OC\Files\Utils\Scanner($user, \OC::$server->getDatabaseConnection(), \OC::$server->getUserFolder($user));
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', array($listener, 'file'));
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', array($listener, 'folder'));
if ($force) {
Expand Down
2 changes: 1 addition & 1 deletion apps/files/command/scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function configure() {
}

protected function scanFiles($user, OutputInterface $output) {
$scanner = new \OC\Files\Utils\Scanner($user, \OC::$server->getDatabaseConnection());
$scanner = new \OC\Files\Utils\Scanner($user, \OC::$server->getDatabaseConnection(), \OC::$server->getUserFolder($user));
$scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) {
$output->writeln("Scanning <info>$path</info>");
});
Expand Down
2 changes: 1 addition & 1 deletion apps/files/tests/ajax_rename.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function setUp() {
\OC_User::createUser(self::$user, 'password');
\OC_User::setUserId(self::$user);

\OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
\OC_Util::setupFS(self::$user);

$l10nMock = $this->getMock('\OC_L10N', array('t'), array(), '', false);
$l10nMock->expects($this->any())
Expand Down
15 changes: 14 additions & 1 deletion apps/files_encryption/hooks/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class Hooks {
// file for which we want to delete the keys after the delete operation was successful
private static $umountedFiles = array();

private static $proxyStatus;

/**
* Startup encryption backend upon user login
* @note This method should never be called for users using client side encryption
Expand Down Expand Up @@ -233,7 +235,7 @@ public static function setPassphrase($params) {
$newUserPassword = $params['password'];

// make sure that the users home is mounted
\OC\Files\Filesystem::initMountPoints($user);
\OC::$server->setupFilesystem($user);

$keypair = Crypt::createKeypair();

Expand Down Expand Up @@ -704,4 +706,15 @@ public static function postUmount($params) {
}
}

/**
* disable encryption while copying the skeleton
*/
public static function preCopySkeleton(){
self::$proxyStatus = \OC_FileProxy::$enabled;
self::$proxyStatus = false;
}

public static function postCopySkeleton() {
\OC_FileProxy::$enabled = self::$proxyStatus;
}
}
4 changes: 4 additions & 0 deletions apps/files_encryption/lib/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public static function registerFilesystemHooks() {
\OCP\Util::connectHook('OC_Filesystem', 'post_umount', 'OCA\Encryption\Hooks', 'postUmount');
\OCP\Util::connectHook('OC_Filesystem', 'umount', 'OCA\Encryption\Hooks', 'preUmount');
\OCP\Util::connectHook('\OC\Core\LostPassword\Controller\LostController', 'post_passwordReset', 'OCA\Encryption\Hooks', 'postPasswordReset');

$factory = \OC::$server->getFilesystemFactory();
$factory->listen('\OC\Files','preCopySkeleton', array('OCA\Encryption\Hooks', 'preCopySkeleton'));
$factory->listen('\OC\Files', 'postCopySkeleton', array('OCA\Encryption\Hooks', 'postCopySkeleton'));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions apps/files_encryption/lib/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function __construct($view, $userId, $client = false) {
$this->privateKeyPath =
$this->encryptionDir . '/' . $this->userId . '.private.key'; // e.g. data/admin/admin.private.key
// make sure that the owners home is mounted
\OC\Files\Filesystem::initMountPoints($userId);
\OC::$server->setupFilesystem($userId);

if (\OCA\Encryption\Helper::isPublicAccess()) {
$this->keyId = $this->publicShareKeyId;
Expand Down Expand Up @@ -1215,7 +1215,7 @@ public function getUidAndFilename($path) {
}

// NOTE: Bah, this dependency should be elsewhere
\OC\Files\Filesystem::initMountPoints($fileOwnerUid);
\OC::$server->setupFilesystem($fileOwnerUid);

// If the file owner is the currently logged in user
if ($fileOwnerUid === $this->userId) {
Expand Down
1 change: 0 additions & 1 deletion apps/files_sharing/ajax/publicpreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
\OC_Util::setupFS($userId);
\OC\Files\Filesystem::initMountPoints($userId);
$view = new \OC\Files\View('/' . $userId . '/files');

$pathId = $linkedItem['file_source'];
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private function getSourceCache($target) {
}
$source = \OC_Share_Backend_File::getSource($target, $this->storage->getMountPoint(), $this->storage->getItemType());
if (isset($source['path']) && isset($source['fileOwner'])) {
\OC\Files\Filesystem::initMountPoints($source['fileOwner']);
\OC::$server->setupFilesystem($source['fileOwner']);
$mounts = \OC\Files\Filesystem::getMountByNumericId($source['storage']);
if (is_array($mounts) and !empty($mounts)) {
$fullPath = $mounts[0]->getMountPoint() . $source['path'];
Expand Down
4 changes: 2 additions & 2 deletions apps/files_sharing/lib/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static function authenticate($linkItem, $password = null) {
public static function getSharesFromItem($target) {
$result = array();
$owner = \OC\Files\Filesystem::getOwner($target);
\OC\Files\Filesystem::initMountPoints($owner);
\OC::$server->setupFilesystem($owner);
$info = \OC\Files\Filesystem::getFileInfo($target);
$ownerView = new \OC\Files\View('/'.$owner.'/files');
if ( $owner != \OCP\User::getUser() ) {
Expand Down Expand Up @@ -179,7 +179,7 @@ public static function getSharesFromItem($target) {

public static function getUidAndFilename($filename) {
$uid = \OC\Files\Filesystem::getOwner($filename);
\OC\Files\Filesystem::initMountPoints($uid);
\OC::$server->setupFilesystem($uid);
if ( $uid != \OCP\User::getUser() ) {
$info = \OC\Files\Filesystem::getFileInfo($filename);
$ownerView = new \OC\Files\View('/'.$uid.'/files');
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/share/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function generateTarget($filePath, $shareWith, $exclude = null) {
return $target;
}

\OC\Files\Filesystem::initMountPoints($shareWith);
\OC::$server->setupFilesystem($shareWith);
$view = new \OC\Files\View('/' . $shareWith . '/files');

if (!$view->is_dir($shareFolder)) {
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/sharedstorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getSourcePath($target) {
$source = $this->getFile($target);
if ($source) {
if (!isset($source['fullPath'])) {
\OC\Files\Filesystem::initMountPoints($source['fileOwner']);
\OC::$server->setupFilesystem($source['fileOwner']);
$mount = \OC\Files\Filesystem::getMountByNumericId($source['storage']);
if (is_array($mount) && !empty($mount)) {
$this->files[$target]['fullPath'] = $mount[key($mount)]->getMountPoint() . $source['path'];
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static private function correctUsersFolder($user, $path) {
// $path points to the mount point which is a virtual folder, so we start with
// the parent
$path = '/files' . dirname($path);
\OC\Files\Filesystem::initMountPoints($user);
\OC::$server->setupFilesystem($user);
$view = new \OC\Files\View('/' . $user);
if ($view->file_exists($path)) {
while ($path !== dirname($path)) {
Expand Down
2 changes: 1 addition & 1 deletion apps/files_trashbin/lib/trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Trashbin {

public static function getUidAndFilename($filename) {
$uid = \OC\Files\Filesystem::getOwner($filename);
\OC\Files\Filesystem::initMountPoints($uid);
\OC::$server->setupFilesystem($uid);
if ($uid != \OCP\User::getUser()) {
$info = \OC\Files\Filesystem::getFileInfo($filename);
$ownerView = new \OC\Files\View('/' . $uid . '/files');
Expand Down
2 changes: 1 addition & 1 deletion apps/files_versions/lib/versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Storage {

public static function getUidAndFilename($filename) {
$uid = \OC\Files\Filesystem::getOwner($filename);
\OC\Files\Filesystem::initMountPoints($uid);
\OC::$server->setupFilesystem($uid);
if ( $uid != \OCP\User::getUser() ) {
$info = \OC\Files\Filesystem::getFileInfo($filename);
$ownerView = new \OC\Files\View('/'.$uid.'/files');
Expand Down
2 changes: 1 addition & 1 deletion lib/private/cache/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function getStorage() {
return $this->storage;
}
if(\OC_User::isLoggedIn()) {
\OC\Files\Filesystem::initMountPoints(\OC_User::getUser());
\OC::$server->setupFilesystem(\OC_User::getUser());
$this->storage = new \OC\Files\View('/' . \OC_User::getUser() . '/cache');
return $this->storage;
}else{
Expand Down
37 changes: 0 additions & 37 deletions lib/private/fileproxy/fileoperations.php

This file was deleted.

Loading

0 comments on commit f01e6d7

Please sign in to comment.