diff options
| author | 2014-09-16 18:30:24 +0200 | |
|---|---|---|
| committer | 2014-09-16 18:30:24 +0200 | |
| commit | a4e43e9c53ac404d16af5d913a56eeb444b1ce10 (patch) | |
| tree | ddd33b85779d86ce78ef8192bb9e707cc32423dc /app | |
| parent | c2ca9805fa61d045fa5466a8c3ba88d8a0c5a299 (diff) | |
Message if last update checking is close
last_update.txt is updated even if there is no update
If last_update.txt has been modified during last hour, show a message
See https://github.com/marienfressinaud/FreshRSS/issues/480#issuecomment-55765373
Diffstat (limited to 'app')
| -rw-r--r-- | app/Controllers/updateController.php | 11 | ||||
| -rw-r--r-- | app/i18n/en.php | 2 | ||||
| -rw-r--r-- | app/i18n/fr.php | 2 | ||||
| -rw-r--r-- | app/views/update/index.phtml | 17 |
4 files changed, 21 insertions, 11 deletions
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php index 4c1dd002c..72244e9c7 100644 --- a/app/Controllers/updateController.php +++ b/app/Controllers/updateController.php @@ -12,9 +12,11 @@ class FreshRSS_update_Controller extends Minz_ActionController { Minz_View::prependTitle(_t('update_system') . ' · '); $this->view->last_update_time = 'unknown'; + $this->view->check_last_hour = false; $timestamp = (int)@file_get_contents(DATA_PATH . '/last_update.txt'); if (is_numeric($timestamp) && $timestamp > 0) { $this->view->last_update_time = timestamptodate($timestamp); + $this->view->check_last_hour = (time() - 3600) <= $timestamp; } } @@ -38,13 +40,10 @@ class FreshRSS_update_Controller extends Minz_ActionController { public function checkAction() { $this->view->change_view('update', 'index'); - // Get the last update. If already check during the last hour, do nothing. - $last_update = (int)@file_get_contents(DATA_PATH . '/last_update.txt'); - $check_last_hour = (time() - 3600) <= $last_update; - - if (file_exists(UPDATE_FILENAME) || $check_last_hour) { + if (file_exists(UPDATE_FILENAME) || $this->view->check_last_hour) { // There is already an update file to apply: we don't need to check // the webserver! + // Or if already check during the last hour, do nothing. Minz_Request::forward(array('c' => 'update')); return; @@ -81,6 +80,8 @@ class FreshRSS_update_Controller extends Minz_ActionController { 'body' => _t('no_update') ); + @file_put_contents(DATA_PATH . '/last_update.txt', time()); + return; } diff --git a/app/i18n/en.php b/app/i18n/en.php index c5911cde7..8f39115ad 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -424,7 +424,7 @@ return array ( 'update' => 'Update', 'update_system' => 'Update system', 'update_check' => 'Check for new updates', - 'update_last' => 'Last update: %s', + 'update_last' => 'Last verification: %s', 'update_can_apply' => 'There is an available update. <a class="btn" href="%s">Apply</a>', 'update_server_not_found' => 'Update server cannot be found. [%s]', 'no_update' => 'No update to apply', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 789a0bb98..48b4c1732 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -424,7 +424,7 @@ return array ( 'update' => 'Mise à jour', 'update_system' => 'Système de mise à jour', 'update_check' => 'Vérifier les mises à jour', - 'update_last' => 'Dernière mise à jour : %s', + 'update_last' => 'Dernière vérification : %s', 'update_can_apply' => 'Il y’a une mise à jour à appliquer. <a class="btn" href="%s">Appliquer la mise à jour</a>', 'update_server_not_found' => 'Le serveur de mise à jour n’a pas été trouvé. [%s]', 'no_update' => 'Aucune mise à jour à appliquer', diff --git a/app/views/update/index.phtml b/app/views/update/index.phtml index 1824c02b8..5be8b1e8b 100644 --- a/app/views/update/index.phtml +++ b/app/views/update/index.phtml @@ -5,17 +5,26 @@ <h1><?php echo _t('update_system'); ?></h1> + <p> + <?php echo _i('help'); ?> <?php echo _t('update_last', $this->last_update_time); ?> + </p> + <?php if (!empty($this->message)) { ?> <p class="alert <?php echo $this->message['status'] === 'bad' ? 'alert-error' : 'alert-warn'; ?>"> <span class="alert-head"><?php echo $this->message['title']; ?></span> <?php echo $this->message['body']; ?> </p> + <?php } elseif ($this->check_last_hour) { ?> + <p class="alert alert-warn"> + <span class="alert-head"><?php echo _t('damn'); ?></span> + <?php echo _t('no_update'); ?> + </p> <?php } ?> - <?php if (empty($this->message) || $this->message['status'] !== 'good') { ?> - <p> - <?php echo _i('help'); ?> <?php echo _t('update_last', $this->last_update_time); ?> - </p> + <?php + if (!$this->check_last_hour && + (empty($this->message) || $this->message['status'] !== 'good')) { + ?> <p> <a href="<?php echo _url('update', 'check'); ?>" class="btn"><?php echo _t('update_check'); ?></a> </p> |
