mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-02 17:07:01 +01:00
Aggiunta resource folder_size
This commit is contained in:
parent
d59df844a6
commit
6976950390
48
modules/stato_servizi/api/retrieve.php
Normal file
48
modules/stato_servizi/api/retrieve.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
use Util\FileSystem;
|
||||
switch ($resource) {
|
||||
case 'folder_size':
|
||||
|
||||
$dirs = $_GET['dirs'];
|
||||
|
||||
if (empty($dirs)) {
|
||||
$backup_dir = App::getConfig()['backup_dir'];
|
||||
$dirs = [
|
||||
$backup_dir => tr('Backup'),
|
||||
'files' => tr('Allegati'),
|
||||
'logs' => tr('Logs'),
|
||||
];
|
||||
}else{
|
||||
$array = explode(",", $dirs);
|
||||
foreach ($array as $key => $value) {
|
||||
$dirs = [
|
||||
$value => $key
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$tot_byte_size = 0;
|
||||
foreach ($dirs as $dir => $description) {
|
||||
|
||||
$size = FileSystem::folderSize($dir);
|
||||
|
||||
$results[] = [
|
||||
'description' => $description,
|
||||
'size' => $size,
|
||||
'formattedSize' => FileSystem::formatBytes($size),
|
||||
];
|
||||
|
||||
$tot_byte_size += $size;
|
||||
|
||||
}
|
||||
|
||||
$results[count($dirs)]['totalbyte'] = $tot_byte_size;
|
||||
|
||||
$response = $results;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return [
|
||||
'folder_size',
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user