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()
{
$partitions = array();
//connect to DB and find how much total space user has allocated.
$totalSpace = Application_Model_Preference::GetDiskQuota();
$usedSpace = Application_Model_Preference::getDiskUsage();
if (empty($usedSpace)) {
$usedSpace = 0;
/* First lets get all the watched directories. Then we can group them
* into the same partitions by comparing the partition sizes. */
$musicDirs = Application_Model_MusicDir::getWatchedDirs();
$musicDirs[] = Application_Model_MusicDir::getStorDir();
foreach ($musicDirs as $md) {
$totalSpace = disk_total_space($md->getDirectory());
if (!isset($partitions[$totalSpace])) {
$partitions[$totalSpace] = new StdClass;
$partitions[$totalSpace]->totalSpace = $totalSpace;
$partitions[$totalSpace]->totalFreeSpace = disk_free_space($md->getDirectory());
$partitions[$totalSpace]->usedSpace = $totalSpace - $partitions[$totalSpace]->totalFreeSpace;
}
$partitions[$totalSpace]->dirs[] = $md->getDirectory();
}
/* $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]->totalFreeSpace = $totalSpace - $usedSpace;
//Logging::info($partitions[$totalSpace]->totalFreeSpace);
return array_values($partitions);
}

View File

@ -17,12 +17,6 @@
$r1 = array_reduce($phpDependencies, "booleanReduce", true);
$r2 = array_reduce($externalServices, "booleanReduce", true);
$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">
@ -159,22 +153,4 @@
<tr id="partitions" class="even">
<th colspan="5"><?php echo _("Disk Space") ?></th>
</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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

After

Width:  |  Height:  |  Size: 263 KiB