@@ -68,7 +68,7 @@ public function getForm(): TemplateResponse {
6868 $ totalSpace = $ this ->humanFileSize ($ storageInfo ['total ' ]);
6969 }
7070
71- $ trashSizeinBytes = self :: getTrashbinSize ($ this ->uid );
71+ $ trashSizeinBytes = $ this -> getTrashbinSize ($ this ->uid );
7272 $ filesSizeInBytes = $ storageInfo ['used ' ] - $ photoVideoSizeInBytes ;
7373
7474 if ($ filesSizeInBytes < 0 ) {
@@ -142,12 +142,35 @@ private function getTariff($quota) {
142142
143143 return $ tariff ;
144144 }
145-
145+ /*
146146 private static function getTrashbinSize($user) {
147147 $view = new View('/' . $user);
148148 $fileInfo = $view->getFileInfo('/files_trashbin');
149149 return isset($fileInfo['size']) ? $fileInfo['size'] : 0;
150150 }
151+ */
152+ private function getTrashbinSize ($ user ) {
153+ $ details = null ;
154+
155+ $ rootFolder = \OC ::$ server ->getRootFolder ()->getUserFolder ($ user );
156+ $ storageId = $ rootFolder ->getStorage ()->getCache ()->getNumericStorageId ();
157+
158+ $ query = $ this ->db ->getQueryBuilder ();
159+
160+ $ query ->selectAlias ($ query ->func ()->sum ('size ' ), 'f1 ' )
161+ ->from ('filecache ' , 'fc ' )
162+ ->where ($ query ->expr ()->neq ('fc.size ' , $ query ->createPositionalParameter (-1 )))
163+ ->andWhere ("fc.path Like 'files_trashbin/files/%' " )
164+ ->andWhere ($ query ->expr ()->eq ('fc.storage ' , $ query ->createPositionalParameter ($ storageId )));
165+
166+ $ result = $ query ->execute ();
167+
168+ while ($ row = $ result ->fetch ()) {
169+ $ details = $ row ['f1 ' ];
170+ }
171+ $ result ->closeCursor ();
172+ return $ details ;
173+ }
151174
152175 private function storageUtilization ($ user = null , $ filterMimetypes = null ) {
153176 $ details = null ;
@@ -204,7 +227,7 @@ private function humanFileSize($bytes, $binary = true) {
204227 return $ relativeSize . ' ' . $ readableFormat ;
205228 }
206229 } else {
207- return $ bytes . ' ' . $ humanList [0 ];
230+ return ' 0 ' . $ humanList [0 ];
208231 }
209232 }
210233}
0 commit comments