diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 62879b0ca853b2114a4be78e8afae71bef822346..7b14a4ec0816ddae30f00be3bdb4c5c0101c8239 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -922,8 +922,11 @@ class Trashbin {
 
 		$view = new \OC\Files\View('/' . $user . '/files_trashbin');
 		$dh = $view->opendir('/files');
+		if (!$dh) {
+			return false;
+		}
 		while ($file = readdir($dh)) {
-			if($file !== '.' and $file !== '..'){
+			if ($file !== '.' and $file !== '..') {
 				return false;
 			}
 		}