summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/trashbin.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-03-10 11:47:52 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-03-10 11:47:52 +0100
commit4ffca58bc4d10ce2d7b63790813ab448c198c23f (patch)
treec38ce96b329556ab57d58039d0f490d803cc0ec6 /apps/files_trashbin/lib/trashbin.php
parent7cb6811a7b23a2fed96bea65b9ea8aaad512e33a (diff)
downloadnextcloud-server-4ffca58bc4d10ce2d7b63790813ab448c198c23f.tar.gz
nextcloud-server-4ffca58bc4d10ce2d7b63790813ab448c198c23f.zip
don't rely on \OCP\User::getUser() - it is not set properly in case of async operations
Diffstat (limited to 'apps/files_trashbin/lib/trashbin.php')
-rw-r--r--apps/files_trashbin/lib/trashbin.php18
1 files changed, 8 insertions, 10 deletions
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 76395cc95d0..38896821c58 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -423,7 +423,7 @@ class Trashbin {
if ($view->is_dir('/files_trashbin/versions/' . $file)) {
$rootView->rename(\OC\Files\Filesystem::normalizePath($user . '/files_trashbin/versions/' . $file), \OC\Files\Filesystem::normalizePath($owner . '/files_versions/' . $ownerPath));
- } else if ($versions = self::getVersionsFromTrash($versionedFile, $timestamp)) {
+ } else if ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) {
foreach ($versions as $v) {
if ($timestamp) {
$rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v . '.d' . $timestamp, $owner . '/files_versions/' . $ownerPath . '.v' . $v);
@@ -527,8 +527,8 @@ class Trashbin {
$file = $filename;
}
- $size += self::deleteVersions($view, $file, $filename, $timestamp);
- $size += self::deleteEncryptionKeys($view, $file, $filename, $timestamp);
+ $size += self::deleteVersions($view, $file, $filename, $timestamp, $user);
+ $size += self::deleteEncryptionKeys($view, $file, $filename, $timestamp, $user);
if ($view->is_dir('/files_trashbin/files/' . $file)) {
$size += self::calculateSize(new \OC\Files\View('/' . $user . '/files_trashbin/files/' . $file));
@@ -549,14 +549,13 @@ class Trashbin {
* @param $timestamp
* @return int
*/
- private static function deleteVersions(\OC\Files\View $view, $file, $filename, $timestamp) {
+ private static function deleteVersions(\OC\Files\View $view, $file, $filename, $timestamp, $user) {
$size = 0;
if (\OCP\App::isEnabled('files_versions')) {
- $user = \OCP\User::getUser();
if ($view->is_dir('files_trashbin/versions/' . $file)) {
$size += self::calculateSize(new \OC\Files\view('/' . $user . '/files_trashbin/versions/' . $file));
$view->unlink('files_trashbin/versions/' . $file);
- } else if ($versions = self::getVersionsFromTrash($filename, $timestamp)) {
+ } else if ($versions = self::getVersionsFromTrash($filename, $timestamp, $user)) {
foreach ($versions as $v) {
if ($timestamp) {
$size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp);
@@ -578,10 +577,9 @@ class Trashbin {
* @param $timestamp
* @return int
*/
- private static function deleteEncryptionKeys(\OC\Files\View $view, $file, $filename, $timestamp) {
+ private static function deleteEncryptionKeys(\OC\Files\View $view, $file, $filename, $timestamp, $user) {
$size = 0;
if (\OCP\App::isEnabled('files_encryption')) {
- $user = \OCP\User::getUser();
$keyfiles = \OC\Files\Filesystem::normalizePath('files_trashbin/keys/' . $filename);
@@ -823,8 +821,8 @@ class Trashbin {
* @param int $timestamp timestamp when the file was deleted
* @return array
*/
- private static function getVersionsFromTrash($filename, $timestamp) {
- $view = new \OC\Files\View('/' . \OCP\User::getUser() . '/files_trashbin/versions');
+ private static function getVersionsFromTrash($filename, $timestamp, $user) {
+ $view = new \OC\Files\View('/' . $user . '/files_trashbin/versions');
$versions = array();
//force rescan of versions, local storage may not have updated the cache