1818
1919abstract class Fetcher {
2020 public const INVALIDATE_AFTER_SECONDS = 3600 ;
21+ public const INVALIDATE_AFTER_SECONDS_UNSTABLE = 900 ;
2122 public const RETRY_AFTER_FAILURE_SECONDS = 300 ;
2223 public const APP_STORE_URL = 'https://apps.nextcloud.com/api/v1 ' ;
2324
@@ -133,12 +134,17 @@ public function get($allowUnstable = false) {
133134 $ file = $ rootFolder ->getFile ($ this ->fileName );
134135 $ jsonBlob = json_decode ($ file ->getContent (), true );
135136
136- // Always get latests apps info if $allowUnstable
137- if (!$ allowUnstable && is_array ($ jsonBlob )) {
137+ if (is_array ($ jsonBlob )) {
138138 // No caching when the version has been updated
139139 if (isset ($ jsonBlob ['ncversion ' ]) && $ jsonBlob ['ncversion ' ] === $ this ->getVersion ()) {
140140 // If the timestamp is older than 3600 seconds request the files new
141- if ((int )$ jsonBlob ['timestamp ' ] > ($ this ->timeFactory ->getTime () - self ::INVALIDATE_AFTER_SECONDS )) {
141+ $ invalidateAfterSeconds = self ::INVALIDATE_AFTER_SECONDS ;
142+
143+ if ($ allowUnstable ) {
144+ $ invalidateAfterSeconds = self ::INVALIDATE_AFTER_SECONDS_UNSTABLE ;
145+ }
146+
147+ if ((int )$ jsonBlob ['timestamp ' ] > ($ this ->timeFactory ->getTime () - $ invalidateAfterSeconds )) {
142148 return $ jsonBlob ['data ' ];
143149 }
144150
@@ -161,11 +167,6 @@ public function get($allowUnstable = false) {
161167 return [];
162168 }
163169
164- // Don't store the apps request file
165- if ($ allowUnstable ) {
166- return $ responseJson ['data ' ];
167- }
168-
169170 $ file ->putContent (json_encode ($ responseJson ));
170171 return json_decode ($ file ->getContent (), true )['data ' ];
171172 } catch (ConnectException $ e ) {
0 commit comments