add the update to add Type to Storage
This commit is contained in:
parent
8abb8a9259
commit
b96b2636bb
|
@ -0,0 +1,17 @@
|
|||
--
|
||||
-- Add Type column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Storage'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'Type'
|
||||
) > 0,
|
||||
"SELECT 'Column Type already exists in Storages'",
|
||||
"ALTER TABLE Storage ADD `Type` enum('local','s3fs') NOT NULL default 'local' AFTER `Name`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -106,15 +106,15 @@ 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;
|
||||
if ( $this->{'Type'} == 's3fs' ) {
|
||||
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 );;
|
||||
}
|
||||
if ( $this->{'Type'} == 's3fs' ) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue