Overview
Comment: | New version check method |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
36bb5b01f03bf62120bb31c2f9e81106 |
User & Date: | bohwaz on 2020-12-04 13:26:57 |
Other Links: | branch diff | manifest | tags |
Context
2020-12-04
| ||
13:27 | Improve UX by using better wording check-in: 2c6709db6e user: bohwaz tags: dev | |
13:26 | New version check method check-in: 36bb5b01f0 user: bohwaz tags: dev | |
13:26 | Check for new versions check-in: b035194fa0 user: bohwaz tags: dev | |
Changes
Modified src/include/lib/Garradin/Utils.php from [8eb825d6d4] to [2099105858].
︙ | ︙ | |||
838 839 840 841 842 843 844 | header(sprintf('Last-Modified: %s GMT', gmdate('D, d M Y H:i:s', $expiry))); header(sprintf('Etag: %s', $hash)); header('Cache-Control: private'); return false; } | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 | header(sprintf('Last-Modified: %s GMT', gmdate('D, d M Y H:i:s', $expiry))); header(sprintf('Etag: %s', $hash)); header('Cache-Control: private'); return false; } static public function getLatestVersion(): ?string { $config = Config::getInstance(); $last = $config->get('last_version_check'); if ($last) { $last = json_decode($last); } // Only check once every two weeks if ($last && $last->time > (time() - 3600 * 24 * 15)) { return $last->version; } $current_version = garradin_version(); $last = (object) ['time' => time(), 'version' => null]; $config->set('last_version_check', json_encode($last)); $config->save(); $list = (new HTTP)->GET(WEBSITE . 'juvlist'); if (!$list) { return null; } $list = json_decode($list); if (!$list) { return null; } $last->version = $current_version; foreach ($list as $item) { if (preg_match('/^garradin-(.*)\.tar\.bz2$/', $item->name, $match) && !preg_match('/alpha|dev|rc|beta/', $match[1]) && version_compare($last->version, $match[1], '<')) { $last->version = $match[1]; } } if ($last->version == $current_version) { $last->version = null; } $config->set('last_version_check', json_encode($last)); $config->save(); return $last->version; } } |