Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
fix(package): update filesize info on form
Browse files Browse the repository at this point in the history
Signed-off-by: Domingo Oropeza <doropeza@teclib.com>
  • Loading branch information
DIOHz0r committed Mar 9, 2018
1 parent 9aacce3 commit 33d630a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions inc/package.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ public function showForm($ID, array $options = []) {
$this, 'name',
['value' => $objectName, 'display' => false]
);
$fields['filesize'] = Toolbox::getSize($fields['filesize']);
if ($this->isNewID($ID)) {
$fields['filesize'] = '';
} else {
$fields['filesize'] = fileSize(FLYVEMDM_PACKAGE_PATH . '/' . $fields['source']);
$fields['filesize'] = Toolbox::getSize($fields['filesize']);
}
$data = [
'withTemplate' => (isset($options['withtemplate']) && $options['withtemplate'] ? '*' : ''),
'canUpdate' => (!$this->isNewID($ID)) && ($this->canUpdate() > 0) || $this->isNewID($ID),
Expand Down Expand Up @@ -272,7 +277,7 @@ public function post_getFromDB() {
if ($this->canView() && $this->canViewItem()) {
$filename = FLYVEMDM_PACKAGE_PATH . '/' . $this->fields['filename'];
$isFile = is_file($filename);
$this->fields['filesize'] = ($isFile) ? fileSize($filename) : 0;
$this->fields['filesize'] = ($isFile) ? fileSize($filename) : $this->fields['filesize'];
$this->fields['mime_type'] = ($isFile) ? mime_content_type($filename) : '';
if (isAPI()
&& (isset($_SERVER['HTTP_ACCEPT']) && $_SERVER['HTTP_ACCEPT'] == 'application/octet-stream'
Expand Down

0 comments on commit 33d630a

Please sign in to comment.