Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit a3f281e

Browse files
author
Charles Ma
committed
BUG: refs #404 Fixed method
1 parent 18d9986 commit a3f281e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

core/models/pdo/FolderModel.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function policyCheck($folderDao, $userDao = null, $policy = 0)
9595
return true;
9696
}//end policyCheck
9797

98-
/** get the size and the number of item in a folder*/
98+
/** get the size and the number of item in a folder*/
9999
public function getSizeFiltered($folders, $userDao = null, $policy = 0)
100100
{
101101
$isAdmin = false;
@@ -161,8 +161,9 @@ public function getSizeFiltered($folders, $userDao = null, $policy = 0)
161161
->union(array($subqueryUser, $subqueryGroup));
162162

163163
$sql = $this->database->select()
164+
->distinct()
164165
->setIntegrityCheck(false)
165-
->from(array('i' => 'item'), array('sum' => 'sum(i.sizebytes)', 'count' => 'count(i.item_id)'))
166+
->from(array('i' => 'item'))
166167
->join(array('i2f' => 'item2folder'),
167168
'( '.$this->database->getDB()->quoteInto('i2f.folder_id IN (?)', $subSqlFolders).'
168169
OR i2f.folder_id = '.$folder->getKey().'
@@ -186,9 +187,14 @@ public function getSizeFiltered($folders, $userDao = null, $policy = 0)
186187
'(
187188
ip.item_id is not null or
188189
ipg.item_id is not null)'
189-
);
190+
)
191+
->group('i.item_id');
190192
}
191193

194+
$sql = $this->database->select()
195+
->setIntegrityCheck(false)
196+
->from(array('i' => $sql), array('sum' => 'sum(i.sizebytes)', 'count' => 'count(i.item_id)'));
197+
192198
$row = $this->database->fetchRow($sql);
193199
$folders[$key]->count = $row['count'];
194200
$folders[$key]->size = $row['sum'];

0 commit comments

Comments
 (0)