Fix delTree(), it shouldn't be passed to the local storage provider unless the user has delete permission

This commit is contained in:
Michael Gapczynski 2011-07-31 15:02:59 -04:00
parent c185743ae9
commit a14a83b9c6
1 changed files with 25 additions and 9 deletions

View File

@ -402,10 +402,6 @@ class OC_Filestorage_Shared extends OC_Filestorage {
OC_Share::setTarget($target, "/");
} else {
OC_Share::pullOutOfFolder($target, "/");
// If this is a folder being deleted, call setTarget in case there are any database entries inside the folder
if (self::is_dir($path)) {
OC_Share::setTarget($target, "/");
}
}
// Delete the database entry
} else {
@ -440,8 +436,8 @@ class OC_Filestorage_Shared extends OC_Filestorage {
}
$this->clearFolderSizeCache($this->getInternalPath($oldTarget));
$this->clearFolderSizeCache($this->getInternalPath($newTarget));
return true;
}
return true;
}
public function copy($path1, $path2) {
@ -502,10 +498,30 @@ class OC_Filestorage_Shared extends OC_Filestorage {
}
public function delTree($path) {
$source = $this->getSource($path);
if ($source) {
$storage = OC_Filesystem::getStorage($source);
return $storage->delTree($this->getInternalPath($source));
$target = $this->datadir.$path;
if (OC_Share::getPermissions($target) & OC_Share::DELETE) {
$source = $this->getSource($path);
if ($source) {
$storage = OC_Filesystem::getStorage($source);
return $storage->delTree($this->getInternalPath($source));
}
} else {
// Check if the folder is inside a shared folder
if (OC_Share::getParentFolders($target)) {
// If entry for folder already exists
if (OC_Share::getItem($target)) {
OC_Share::setTarget($target, "/");
} else {
OC_Share::pullOutOfFolder($target, "/");
// Call setTarget in case there are any database entries for items inside this folder
OC_Share::setTarget($target, "/");
}
// Delete the database entry
} else {
OC_Share::unshareFromMySelf($target);
}
$this->clearFolderSizeCache($this->getInternalPath($target));
return true;
}
}