only count event size when s3

This commit is contained in:
Isaac Connor 2017-10-11 14:10:53 -04:00
parent e16d852248
commit 3f01f887aa
1 changed files with 10 additions and 5 deletions

View File

@ -105,13 +105,18 @@ class Storage {
# This isn't a function like this in php, so we have to add up the space used in each event.
if ( ! array_key_exists( 'disk_used_space', $this ) ) {
$used = 0;
foreach ( Event::find_all( array( 'StorageId'=>$this->Id() ) ) as $Event ) {
$Event->Storage( $this ); // Prevent further db hit
$used += $Event->DiskSpace();
}
if ( $this->{'type'} == 's3' ) {
foreach ( Event::find_all( array( 'StorageId'=>$this->Id() ) ) as $Event ) {
$Event->Storage( $this ); // Prevent further db hit
$used += $Event->DiskSpace();
}
} else {
$path = $this->Path();
$used = disk_total_space( $path ) - disk_free_space( $path );;
}
$this->{'disk_used_space'} = $used;
}
return $this->{'disk_used_space'};
}
}