summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Gapczynski <GapczynskiM@gmail.com>2011-08-17 12:58:09 -0400
committerMichael Gapczynski <GapczynskiM@gmail.com>2011-08-17 12:58:09 -0400
commit592569737495233a0018e6aff6869fc328b8a142 (patch)
tree4611c652b4e80af553ef572388fea958adb83c8c
parent683e1250427d75d0d3431c486967059871850d6a (diff)
downloadnextcloud-server-592569737495233a0018e6aff6869fc328b8a142.tar.gz
nextcloud-server-592569737495233a0018e6aff6869fc328b8a142.zip
Fix bug in getPermissions() and clean-up unlink() and rename()
-rw-r--r--apps/files_sharing/lib_share.php4
-rw-r--r--apps/files_sharing/sharedstorage.php64
2 files changed, 29 insertions, 39 deletions
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
index f682e1a30f1..a4223a137d1 100644
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -264,9 +264,9 @@ class OC_Share {
if (count($result) > 0) {
return $result[0]['permissions'];
} else {
- $folders =self::getParentFolders($target);
+ $folders = self::getParentFolders($target);
if ($folders == true) {
- $result = $query->execute(array($folders))->fetchAll();
+ $result = $query->execute(array($folders['target']))->fetchAll();
if (count($result) > 0) {
return $result[0]['permissions'];
}
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index 271819782b7..03385d649cb 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -392,48 +392,36 @@ class OC_Filestorage_Shared extends OC_Filestorage {
}
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
- } else {
- // Check if the item is inside a shared folder
- if (OC_Share::getParentFolders($target)) {
- // If entry for item already exists
- if (OC_Share::getItem($target)) {
- OC_Share::setTarget($target, "/");
- } else {
- OC_Share::pullOutOfFolder($target, "/");
- }
- // Delete the database entry
+ $target = $this->datadir.$path;
+ // Check if the item is inside a shared folder
+ if (OC_Share::getParentFolders($target)) {
+ // If entry for item already exists
+ if (OC_Share::getItem($target)) {
+ OC_Share::setTarget($target, "/");
} else {
- OC_Share::unshareFromMySelf($target);
+ OC_Share::pullOutOfFolder($target, "/");
}
- $this->clearFolderSizeCache($this->getInternalPath($target));
+ // Delete the database entry
+ } else {
+ OC_Share::unshareFromMySelf($target);
}
+ $this->clearFolderSizeCache($this->getInternalPath($target));
return true;
}
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;
- $newTarget = $this->datadir.$path2;
- if (OC_Share::getItem($oldTarget)) {
- OC_Share::setTarget($oldTarget, $newTarget);
- // There is no entry in the database for the item, it must be inside a shared folder
+ $oldTarget = $this->datadir.$path1;
+ $newTarget = $this->datadir.$path2;
+ // Check if the item is inside a shared folder
+ if (OC_Share::getParentFolders($oldTarget)) {
+ 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 {
OC_Share::pullOutOfFolder($oldTarget, $newTarget);
// If this is a folder being renamed, call setTarget in case there are any database entries inside the folder
@@ -441,10 +429,12 @@ class OC_Filestorage_Shared extends OC_Filestorage {
OC_Share::setTarget($oldTarget, $newTarget);
}
}
- $this->clearFolderSizeCache($this->getInternalPath($oldTarget));
- $this->clearFolderSizeCache($this->getInternalPath($newTarget));
- return true;
+ } else {
+ OC_Share::setTarget($oldTarget, $newTarget);
}
+ $this->clearFolderSizeCache($this->getInternalPath($oldTarget));
+ $this->clearFolderSizeCache($this->getInternalPath($newTarget));
+ return true;
}
public function copy($path1, $path2) {