Don't try to addup/update DIskSpace used by incomplete events.
This commit is contained in:
parent
4d739f35ef
commit
5d826fd558
|
@ -132,19 +132,7 @@ class Storage extends ZM_Object {
|
||||||
public function event_disk_space() {
|
public function event_disk_space() {
|
||||||
# This isn't a function like this in php, so we have to add up the space used in each event.
|
# This isn't a function like this in php, so we have to add up the space used in each event.
|
||||||
if ( (! property_exists($this, 'DiskSpace')) or (!isset($this->{'DiskSpace'})) ) {
|
if ( (! property_exists($this, 'DiskSpace')) or (!isset($this->{'DiskSpace'})) ) {
|
||||||
$used = dbFetchOne('SELECT SUM(DiskSpace) AS DiskSpace FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this->Id()));
|
$this->{'DiskSpace'} = dbFetchOne('SELECT SUM(DiskSpace) AS DiskSpace FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this->Id()));
|
||||||
|
|
||||||
do {
|
|
||||||
# Do in batches of 1000 so as to not useup all ram, Event will do caching though...
|
|
||||||
$events = Event::find(array('StorageId'=>$this->Id(), 'DiskSpace'=>null), array('limit'=>1000));
|
|
||||||
foreach ( $events as $Event ) {
|
|
||||||
$Event->Storage($this); // Prevent further db hit
|
|
||||||
# DiskSpace will update the event
|
|
||||||
$used += $Event->DiskSpace();
|
|
||||||
} #end foreach
|
|
||||||
Event::clear_cache();
|
|
||||||
} while ( count($events) == 1000 );
|
|
||||||
$this->{'DiskSpace'} = $used;
|
|
||||||
}
|
}
|
||||||
return $this->{'DiskSpace'};
|
return $this->{'DiskSpace'};
|
||||||
} // end function event_disk_space
|
} // end function event_disk_space
|
||||||
|
|
Loading…
Reference in New Issue