Fix bug in getPermissions() and clean-up unlink() and rename()
This commit is contained in:
parent
683e125042
commit
5925697374
|
@ -264,9 +264,9 @@ class OC_Share {
|
||||||
if (count($result) > 0) {
|
if (count($result) > 0) {
|
||||||
return $result[0]['permissions'];
|
return $result[0]['permissions'];
|
||||||
} else {
|
} else {
|
||||||
$folders =self::getParentFolders($target);
|
$folders = self::getParentFolders($target);
|
||||||
if ($folders == true) {
|
if ($folders == true) {
|
||||||
$result = $query->execute(array($folders))->fetchAll();
|
$result = $query->execute(array($folders['target']))->fetchAll();
|
||||||
if (count($result) > 0) {
|
if (count($result) > 0) {
|
||||||
return $result[0]['permissions'];
|
return $result[0]['permissions'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,16 +392,8 @@ class OC_Filestorage_Shared extends OC_Filestorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unlink($path) {
|
public function unlink($path) {
|
||||||
$target = $this->datadir.$path;
|
|
||||||
// If the user has delete permission for the item, the source item will be deleted
|
|
||||||
if (OC_Share::getPermissions($target) & OC_Share::DELETE) {
|
|
||||||
$source = $this->getSource($path);
|
|
||||||
if ($source) {
|
|
||||||
$storage = OC_Filesystem::getStorage($source);
|
|
||||||
return $storage->unlink($this->getInternalPath($source));
|
|
||||||
}
|
|
||||||
// The item will be removed from the database, but won't be touched on the owner's filesystem
|
// The item will be removed from the database, but won't be touched on the owner's filesystem
|
||||||
} else {
|
$target = $this->datadir.$path;
|
||||||
// Check if the item is inside a shared folder
|
// Check if the item is inside a shared folder
|
||||||
if (OC_Share::getParentFolders($target)) {
|
if (OC_Share::getParentFolders($target)) {
|
||||||
// If entry for item already exists
|
// If entry for item already exists
|
||||||
|
@ -415,25 +407,21 @@ class OC_Filestorage_Shared extends OC_Filestorage {
|
||||||
OC_Share::unshareFromMySelf($target);
|
OC_Share::unshareFromMySelf($target);
|
||||||
}
|
}
|
||||||
$this->clearFolderSizeCache($this->getInternalPath($target));
|
$this->clearFolderSizeCache($this->getInternalPath($target));
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rename($path1, $path2) {
|
public function rename($path1, $path2) {
|
||||||
// If the user has write permission for the item, the source item will be renamed
|
|
||||||
if ($this->is_writeable($path1)) {
|
|
||||||
$source = $this->getSource($path1);
|
|
||||||
if ($source) {
|
|
||||||
$storage = OC_Filesystem::getStorage($source);
|
|
||||||
return $storage->rename($path1, $path2);
|
|
||||||
}
|
|
||||||
// The item will be renamed in the database, but won't be touched on the owner's filesystem
|
|
||||||
} else {
|
|
||||||
$oldTarget = $this->datadir.$path1;
|
$oldTarget = $this->datadir.$path1;
|
||||||
$newTarget = $this->datadir.$path2;
|
$newTarget = $this->datadir.$path2;
|
||||||
if (OC_Share::getItem($oldTarget)) {
|
// Check if the item is inside a shared folder
|
||||||
OC_Share::setTarget($oldTarget, $newTarget);
|
if (OC_Share::getParentFolders($oldTarget)) {
|
||||||
// There is no entry in the database for the item, it must be inside a shared folder
|
if ($this->is_writeable($path1)) {
|
||||||
|
$oldSource = $this->getSource($path1);
|
||||||
|
$newSource = dirname($oldSource)."/".basename($path2);
|
||||||
|
if ($oldSource) {
|
||||||
|
$storage = OC_Filesystem::getStorage($oldSource);
|
||||||
|
return $storage->rename($this->getInternalPath($oldSource), $this->getInternalPath($newSource));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
OC_Share::pullOutOfFolder($oldTarget, $newTarget);
|
OC_Share::pullOutOfFolder($oldTarget, $newTarget);
|
||||||
// If this is a folder being renamed, call setTarget in case there are any database entries inside the folder
|
// If this is a folder being renamed, call setTarget in case there are any database entries inside the folder
|
||||||
|
@ -441,11 +429,13 @@ class OC_Filestorage_Shared extends OC_Filestorage {
|
||||||
OC_Share::setTarget($oldTarget, $newTarget);
|
OC_Share::setTarget($oldTarget, $newTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
OC_Share::setTarget($oldTarget, $newTarget);
|
||||||
|
}
|
||||||
$this->clearFolderSizeCache($this->getInternalPath($oldTarget));
|
$this->clearFolderSizeCache($this->getInternalPath($oldTarget));
|
||||||
$this->clearFolderSizeCache($this->getInternalPath($newTarget));
|
$this->clearFolderSizeCache($this->getInternalPath($newTarget));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function copy($path1, $path2) {
|
public function copy($path1, $path2) {
|
||||||
if ($path2 == "" || $path2 == "/") {
|
if ($path2 == "" || $path2 == "/") {
|
||||||
|
|
Loading…
Reference in New Issue