Restore full disk usage not based on quota

This is mostly a restore of how this used to be implemented.
This commit is contained in:
Lucas Bickel 2017-03-08 15:55:33 +01:00
parent b15abbd82f
commit 70e6135e93
3 changed files with 13 additions and 44 deletions

View File

@ -214,27 +214,20 @@ class Application_Model_Systemstatus
public static function GetDiskInfo() public static function GetDiskInfo()
{ {
$partitions = array(); $partitions = array();
/* First lets get all the watched directories. Then we can group them
//connect to DB and find how much total space user has allocated. * into the same partitions by comparing the partition sizes. */
$totalSpace = Application_Model_Preference::GetDiskQuota(); $musicDirs = Application_Model_MusicDir::getWatchedDirs();
$musicDirs[] = Application_Model_MusicDir::getStorDir();
$usedSpace = Application_Model_Preference::getDiskUsage(); foreach ($musicDirs as $md) {
if (empty($usedSpace)) { $totalSpace = disk_total_space($md->getDirectory());
$usedSpace = 0; if (!isset($partitions[$totalSpace])) {
} $partitions[$totalSpace] = new StdClass;
/* $path = $_SERVER['AIRTIME_BASE']."etc/airtime/num_bytes.ini";
$arr = parse_ini_file($path);
$usedSpace = 0;
if ($arr !== false) {
$usedSpace = $arr['num_bytes'];
} */
$partitions[$totalSpace] = new stdClass();
$partitions[$totalSpace]->totalSpace = $totalSpace; $partitions[$totalSpace]->totalSpace = $totalSpace;
$partitions[$totalSpace]->totalFreeSpace = $totalSpace - $usedSpace; $partitions[$totalSpace]->totalFreeSpace = disk_free_space($md->getDirectory());
//Logging::info($partitions[$totalSpace]->totalFreeSpace); $partitions[$totalSpace]->usedSpace = $totalSpace - $partitions[$totalSpace]->totalFreeSpace;
}
$partitions[$totalSpace]->dirs[] = $md->getDirectory();
}
return array_values($partitions); return array_values($partitions);
} }

View File

@ -17,12 +17,6 @@
$r1 = array_reduce($phpDependencies, "booleanReduce", true); $r1 = array_reduce($phpDependencies, "booleanReduce", true);
$r2 = array_reduce($externalServices, "booleanReduce", true); $r2 = array_reduce($externalServices, "booleanReduce", true);
$result = $r1 && $r2; $result = $r1 && $r2;
// Disk information. We only use the [0]th index
// because we don't have Watched/Media Folders
$disk = $this->status->partitions[0];
$used = $disk->totalSpace-$disk->totalFreeSpace;
$total = $disk->totalSpace;
?> ?>
<table width="60%" cellpadding="0" cellspacing="0" border="0" class="statustable"> <table width="60%" cellpadding="0" cellspacing="0" border="0" class="statustable">
@ -159,22 +153,4 @@
<tr id="partitions" class="even"> <tr id="partitions" class="even">
<th colspan="5"><?php echo _("Disk Space") ?></th> <th colspan="5"><?php echo _("Disk Space") ?></th>
</tr> </tr>
<tr class="partition-info">
<td><span class="strong"><?php echo _("Disk") ?></span>
<ul id="watched-dir-list">
</ul>
</td>
<td>
<?php
echo sprintf("%01.1fGB of %01.1fGB", $used/pow(2, 30), $total/pow(2, 30))
?>
</td>
<td colspan="3">
<div class="big">
<div class="diskspace" style="width:<?php echo sprintf("%01.1f%%", $used/$total*100) ?>;">
</div>
</div>
<div><?php echo sprintf("%01.1f%% ", $used/$total*100) . _("in use") ?></div>
</td>
</tr>
</table> </table>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

After

Width:  |  Height:  |  Size: 263 KiB