aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/ajax/upload.php29
-rw-r--r--apps/files_sharing/public.php18
-rw-r--r--lib/public/share.php23
3 files changed, 39 insertions, 31 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index fd6aa981542..0a61ff72d41 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -27,25 +27,24 @@ if (empty($_POST['dirToken'])) {
if (!($linkItem['permissions'] & OCP\PERMISSION_CREATE)) {
OCP\JSON::checkLoggedIn();
} else {
+ // resolve reshares
+ $rootLinkItem = OCP\Share::resolveReShare($linkItem);
+
+ // Setup FS with owner
+ OC_Util::setupFS($rootLinkItem['uid_owner']);
// The token defines the target directory (security reasons)
+ $path = \OC\Files\Filesystem::getPath($linkItem['file_source']);
$dir = sprintf(
"/%s/%s",
- $linkItem['file_target'],
+ $path,
isset($_POST['subdir']) ? $_POST['subdir'] : ''
);
- // handle reshare
- if (!empty($linkItem['parent'])) {
- $dir = '/Shared'.$dir;
- }
-
if (!$dir || empty($dir) || $dir === false) {
OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
die();
}
- // Setup FS with owner
- OC_Util::setupFS($linkItem['uid_owner']);
}
}
@@ -81,17 +80,17 @@ $files = $_FILES['files'];
$error = '';
-$maxUploadFilesize = OCP\Util::maxUploadFilesize($dir);
-$maxHumanFilesize = OCP\Util::humanFileSize($maxUploadFilesize);
+$maxUploadFileSize = $storageStats['uploadMaxFilesize'];
+$maxHumanFileSize = OCP\Util::humanFileSize($maxUploadFileSize);
$totalSize = 0;
foreach ($files['size'] as $size) {
$totalSize += $size;
}
-if ($maxUploadFilesize >= 0 and $totalSize > $maxUploadFilesize) {
+if ($maxUploadFileSize >= 0 and $totalSize > $maxUploadFileSize) {
OCP\JSON::error(array('data' => array('message' => $l->t('Not enough storage available'),
- 'uploadMaxFilesize' => $maxUploadFilesize,
- 'maxHumanFilesize' => $maxHumanFilesize)));
+ 'uploadMaxFilesize' => $maxUploadFileSize,
+ 'maxHumanFilesize' => $maxHumanFileSize)));
exit();
}
@@ -113,8 +112,8 @@ if (strpos($dir, '..') === false) {
'id' => $meta['fileid'],
'name' => basename($target),
'originalname' => $files['name'][$i],
- 'uploadMaxFilesize' => $maxUploadFilesize,
- 'maxHumanFilesize' => $maxHumanFilesize
+ 'uploadMaxFilesize' => $maxUploadFileSize,
+ 'maxHumanFilesize' => $maxHumanFileSize
);
}
}
diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php
index fb18bc26248..7c9158d8002 100644
--- a/apps/files_sharing/public.php
+++ b/apps/files_sharing/public.php
@@ -27,23 +27,9 @@ if (isset($_GET['t'])) {
$type = $linkItem['item_type'];
$fileSource = $linkItem['file_source'];
$shareOwner = $linkItem['uid_owner'];
- $fileOwner = null;
$path = null;
- if (isset($linkItem['parent'])) {
- $parent = $linkItem['parent'];
- while (isset($parent)) {
- $query = \OC_DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1);
- $item = $query->execute(array($parent))->fetchRow();
- if (isset($item['parent'])) {
- $parent = $item['parent'];
- } else {
- $fileOwner = $item['uid_owner'];
- break;
- }
- }
- } else {
- $fileOwner = $shareOwner;
- }
+ $rootLinkItem = OCP\Share::resolveReShare($linkItem);
+ $fileOwner = $rootLinkItem['uid_owner'];
if (isset($fileOwner)) {
OC_Util::tearDownFS();
OC_Util::setupFS($fileOwner);
diff --git a/lib/public/share.php b/lib/public/share.php
index de7025d7b15..69e6f35b473 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -292,6 +292,29 @@ class Share {
}
/**
+ * @brief resolves reshares down to the last real share
+ * @param $linkItem
+ * @return $fileOwner
+ */
+ public static function resolveReShare($linkItem)
+ {
+ if (isset($linkItem['parent'])) {
+ $parent = $linkItem['parent'];
+ while (isset($parent)) {
+ $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `id` = ?', 1);
+ $item = $query->execute(array($parent))->fetchRow();
+ if (isset($item['parent'])) {
+ $parent = $item['parent'];
+ } else {
+ return $item;
+ }
+ }
+ }
+ return $linkItem;
+ }
+
+
+ /**
* @brief Get the shared items of item type owned by the current user
* @param string Item type
* @param int Format (optional) Format type must be defined by the backend