Fix bug in opendir() and remove getStorageMountPoint(), now using datadir argument instead
This commit is contained in:
parent
e202c29926
commit
6b303ee64b
|
@ -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) {
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -215,15 +215,6 @@ class OC_FILESYSTEM{
|
|||
return $foundMountPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
Loading…
Reference in New Issue