From 7bed529951110b173a6a8e8a49b774c2d5e5ab19 Mon Sep 17 00:00:00 2001
From: Vincent Petry <pvince81@owncloud.com>
Date: Tue, 16 Feb 2016 16:29:07 +0100
Subject: [PATCH] Don't resize trash when no user

Happens when overwriting files on federated shares.
---
 apps/files_trashbin/lib/hooks.php | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/apps/files_trashbin/lib/hooks.php b/apps/files_trashbin/lib/hooks.php
index 0a018f4f0f..9fb6c162b6 100644
--- a/apps/files_trashbin/lib/hooks.php
+++ b/apps/files_trashbin/lib/hooks.php
@@ -40,10 +40,13 @@ class Hooks {
 		if( \OCP\App::isEnabled('files_trashbin') ) {
 			$uid = $params['uid'];
 			Trashbin::deleteUser($uid);
-			}
+		}
 	}
 
 	public static function post_write_hook($params) {
-		Trashbin::resizeTrash(\OCP\User::getUser());
+		$user = \OCP\User::getUser();
+		if (!empty($user)) {
+			Trashbin::resizeTrash($user);
+		}
 	}
 }
-- 
GitLab