Skip to content

Commit

Permalink
Use bigint for disks size (#16845)
Browse files Browse the repository at this point in the history
* Use bigint for disks size

closes #16844

* Add unit sizes
  • Loading branch information
trasher authored Mar 28, 2024
1 parent 0458112 commit c025914
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
41 changes: 41 additions & 0 deletions install/migrations/update_10.0.4_to_10.0.5/items_disks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* ---------------------------------------------------------------------
*
* GLPI - Gestionnaire Libre de Parc Informatique
*
* http://glpi-project.org
*
* @copyright 2015-2024 Teclib' and contributors.
* @copyright 2003-2014 by the INDEPNET Development Team.
* @licence https://www.gnu.org/licenses/gpl-3.0.html
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* ---------------------------------------------------------------------
*/

/**
* @var \Migration $migration
*/

$migration->changeField('glpi_items_disks', 'totalsize', 'totalsize', 'bigint NOT NULL DEFAULT "0"');
$migration->changeField('glpi_items_disks', 'freesize', 'freesize', 'bigint NOT NULL DEFAULT "0"');
4 changes: 2 additions & 2 deletions install/mysql/glpi-empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,8 @@ CREATE TABLE `glpi_items_disks` (
`device` varchar(255) DEFAULT NULL,
`mountpoint` varchar(255) DEFAULT NULL,
`filesystems_id` int unsigned NOT NULL DEFAULT '0',
`totalsize` int NOT NULL DEFAULT '0',
`freesize` int NOT NULL DEFAULT '0',
`totalsize` bigint NOT NULL DEFAULT '0',
`freesize` bigint NOT NULL DEFAULT '0',
`is_deleted` tinyint NOT NULL DEFAULT '0',
`is_dynamic` tinyint NOT NULL DEFAULT '0',
`encryption_status` int NOT NULL DEFAULT '0',
Expand Down
2 changes: 1 addition & 1 deletion src/Toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ public static function getSize($size)
{

//TRANS: list of unit (o for octet)
$bytes = [__('o'), __('Kio'), __('Mio'), __('Gio'), __('Tio')];
$bytes = [__('o'), __('Kio'), __('Mio'), __('Gio'), __('Tio'), __('Pio'), __('Eio'), __('Zio'), __('Yio')];
foreach ($bytes as $val) {
if ($size > 1024) {
$size = $size / 1024;
Expand Down
13 changes: 8 additions & 5 deletions tests/functional/Toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,14 @@ public function testFilename($name, $expected)
public function dataGetSize()
{
return [
[1, '1 o'],
[1025, '1 Kio'],
[1100000, '1.05 Mio'],
[1100000000, '1.02 Gio'],
[1100000000000, '1 Tio'],
[1, '1 o'],
[1025, '1 Kio'],
[1100000, '1.05 Mio'],
[1100000000, '1.02 Gio'],
[1100000000000, '1 Tio'],
[1100000000000 * 1024, '1 Pio'],
[1100000000000 * 1024 * 1024, '1 Eio'],
[1100000000000 * 1024 * 1024 * 1024, '1 Zio'],
];
}

Expand Down

0 comments on commit c025914

Please sign in to comment.