Skip to content

Commit

Permalink
Fix metadata beta determination (#51)
Browse files Browse the repository at this point in the history
* Fix metadata beta determination

* Refactor beta version determination

* Move `$this->collectMetadata();` in `Package` constructor
  • Loading branch information
itn3rd77 authored and jdel committed Jul 24, 2018
1 parent a481982 commit 5f62bed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
16 changes: 4 additions & 12 deletions lib/SSpkS/Package/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public function __construct(\SSpkS\Config $config, $filename)
$this->metafile = $this->filepathNoExt . '.nfo';
$this->wizfile = $this->filepathNoExt . '.wiz';
$this->nowizfile = $this->filepathNoExt . '.nowiz';
// Make sure we have metadata available
$this->collectMetadata();
}

/**
Expand All @@ -72,7 +74,6 @@ public function __construct(\SSpkS\Config $config, $filename)
*/
public function __get($name)
{
$this->collectMetadata();
return $this->metadata[$name];
}

Expand All @@ -84,7 +85,6 @@ public function __get($name)
*/
public function __set($name, $value)
{
$this->collectMetadata();
$this->metadata[$name] = $value;
}

Expand All @@ -96,7 +96,6 @@ public function __set($name, $value)
*/
public function __isset($name)
{
$this->collectMetadata();
return isset($this->metadata[$name]);
}

Expand All @@ -107,7 +106,6 @@ public function __isset($name)
*/
public function __unset($name)
{
$this->collectMetadata();
unset($this->metadata[$name]);
}

Expand Down Expand Up @@ -159,7 +157,7 @@ private function collectMetadata()
$this->fixBoolIfExist('silent_uninstall');
$this->fixBoolIfExist('silent_upgrade');

if (isset($this->metadata['beta']) && in_array($this->metadata['beta'], array('true', '1', 'beta'))) {
if ($this->isBeta()) {
$this->metadata['beta'] = true;
} else {
$this->metadata['beta'] = false;
Expand All @@ -180,7 +178,6 @@ private function collectMetadata()
*/
public function getMetadata()
{
$this->collectMetadata();
return $this->metadata;
}

Expand Down Expand Up @@ -282,7 +279,6 @@ public function getThumbnails($pathPrefix = '')
$this->extractIfMissing($sourceList['file'], $thumbName);
} catch (\Exception $e) {
// Check if icon is in metadata
$this->collectMetadata();
if (isset($this->metadata[$sourceList['info']])) {
file_put_contents($thumbName, base64_decode($this->metadata[$sourceList['info']]));
}
Expand Down Expand Up @@ -334,8 +330,6 @@ public function getSnapshots($pathPrefix = '')
*/
public function isCompatibleToArch($arch)
{
// Make sure we have metadata available
$this->collectMetadata();
// TODO: Check arch family, too?
return (in_array($arch, $this->metadata['arch']) || in_array('noarch', $this->metadata['arch']));
}
Expand All @@ -348,7 +342,6 @@ public function isCompatibleToArch($arch)
*/
public function isCompatibleToFirmware($version)
{
$this->collectMetadata();
return version_compare($this->metadata['firmware'], $version, '<=');
}

Expand All @@ -359,7 +352,6 @@ public function isCompatibleToFirmware($version)
*/
public function isBeta()
{
$this->collectMetadata();
return (isset($this->metadata['beta']) && $this->metadata['beta'] == true);
return (isset($this->metadata['beta']) && $this->parseBool($this->metadata['beta']));
}
}
2 changes: 1 addition & 1 deletion lib/SSpkS/Package/PackageFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function isMatchingChannel($package)
if ($this->filterChannel === false) {
return true;
}
if ($this->filterChannel == 'stable' && (!isset($package->beta) || $package->beta === false)) {
if ($this->filterChannel == 'stable' && $package->isBeta() === false) {
return true;
} elseif ($this->filterChannel == 'beta') {
return true;
Expand Down

0 comments on commit 5f62bed

Please sign in to comment.