diff options
author | Michael Gapczynski <GapczynskiM@gmail.com> | 2011-07-12 13:10:29 -0400 |
---|---|---|
committer | Michael Gapczynski <GapczynskiM@gmail.com> | 2011-07-12 13:10:29 -0400 |
commit | 6b303ee64b5c1b1e338c9bbf1b895d33b140985d (patch) | |
tree | 83878e2eeecedefe8eebd846e70ea7bc3f317d15 | |
parent | e202c299267549a88faf286e85899225616178a2 (diff) | |
download | nextcloud-server-6b303ee64b5c1b1e338c9bbf1b895d33b140985d.tar.gz nextcloud-server-6b303ee64b5c1b1e338c9bbf1b895d33b140985d.zip |
Fix bug in opendir() and remove getStorageMountPoint(), now using datadir argument instead
-rw-r--r-- | apps/files_sharing/sharedstorage.php | 28 | ||||
-rw-r--r-- | lib/base.php | 2 | ||||
-rw-r--r-- | lib/filesystem.php | 9 |
3 files changed, 13 insertions, 26 deletions
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php index 3b678178c36..b0770cbfdba 100644 --- a/apps/files_sharing/sharedstorage.php +++ b/apps/files_sharing/sharedstorage.php @@ -29,11 +29,11 @@ OC_FILESYSTEM::registerStorageType('shared','OC_FILESTORAGE_SHARED',array('datad */ class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE { + private $datadir; private $sourcePaths = array(); - // TODO uh... I don't know what to do here - public function __construct($parameters) { - + public function __construct($arguments) { + $this->datadir = $arguments['datadir']; } public function getInternalPath($path) { @@ -43,7 +43,7 @@ class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE { } public function getSource($target) { - $target = OC_FILESYSTEM::getStorageMountPoint($this).$target; + $target = $this->datadir.$target; if (array_key_exists($target, $this->sourcePaths)) { return $this->sourcePaths[$target]; } else { @@ -59,8 +59,7 @@ class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE { } else { $source = $this->getSource($path); if ($source) { - $target = OC_FILESYSTEM::getStorageMountPoint($this).$path; - if (OC_SHARE::isWriteable($target)) { + if (OC_SHARE::isWriteable($this->datadir.$path)) { $storage = OC_FILESYSTEM::getStorage($source); return $storage->mkdir($this->getInternalPath($source)); } @@ -70,16 +69,17 @@ class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE { public function rmdir($path) { // The folder will be removed from the database, but won't be deleted from the owner's filesystem - $target = OC_FILESYSTEM::getStorageMountPoint($this).$path; - OC_SHARE::unshareFromSelf($target); + OC_SHARE::unshareFromSelf($this->datadir.$path); } + // TODO Make sure new target is still in the current directory public function opendir($path) { if ($path == "" || $path == "/") { global $FAKEDIRS; $sharedItems = OC_SHARE::getItemsSharedWith(); foreach ($sharedItems as $item) { - $files[] = $item['target']; + // TODO Implement a better fix + $files[] = substr($item['target'], strpos($item['target'], "Share") + 5); } $FAKEDIRS['shared'] = $files; return opendir('fakedir://shared'); @@ -242,8 +242,7 @@ class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE { if ($path == "" || $path == "/") { return true; } else { - $target = OC_FILESYSTEM::getStorageMountPoint($this).$path; - return OC_SHARE::isWriteable($target); + return OC_SHARE::isWriteable($this->datadir.$path); } } @@ -346,14 +345,11 @@ class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE { public function unlink($path) { // The file will be removed from the database, but won't be deleted from the owner's filesystem - $target = OC_FILESYSTEM::getStorageMountPoint($this).$path; - OC_SHARE::unshareFromSelf($target); + OC_SHARE::unshareFromSelf($this->datadir.$path); } public function rename($path1, $path2) { - $oldTarget = OC_FILESYSTEM::getStorageMountPoint($this).$path1; - $newTarget = OC_FILESYSTEM::getStorageMountPoint($this).$path2; - OC_SHARE::setTarget($oldTarget, $newTarget); + OC_SHARE::setTarget($this->datadir.$path1, $this->datadir.$path2); } public function copy($path1, $path2) { diff --git a/lib/base.php b/lib/base.php index 4250274c7c3..d369b392a4f 100644 --- a/lib/base.php +++ b/lib/base.php @@ -166,7 +166,7 @@ class OC_UTIL { OC_FILESYSTEM::mount($rootStorage,'/'); // TODO add this storage provider in a proper way - $sharedStorage = OC_FILESYSTEM::createStorage('shared',array('datadir'=>$CONFIG_DATADIRECTORY)); + $sharedStorage = OC_FILESYSTEM::createStorage('shared',array('datadir'=>'/MTGap/files/Share/')); OC_FILESYSTEM::mount($sharedStorage,'MTGap/files/Share/'); $CONFIG_DATADIRECTORY = "$CONFIG_DATADIRECTORY_ROOT/$user/$root"; diff --git a/lib/filesystem.php b/lib/filesystem.php index c7e2070fa0a..1f96e139ab3 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -216,15 +216,6 @@ class OC_FILESYSTEM{ } /** - * get the mountpoint of the storage object - * @param OC_FILESTORAGE storage - * @return string - */ - static public function getStorageMountPoint($storage){ - return array_search($storage, self::$storages); - } - - /** * return the path to a local version of the file * we need this because we can't know if a file is stored local or not from outside the filestorage and for some purposes a local file is needed * @param string path |