diff options
| author | 2015-01-13 12:02:35 +0100 | |
|---|---|---|
| committer | 2015-01-13 12:02:35 +0100 | |
| commit | e7c24b5d41c293fa13e4d92efb2aee7778ddcab4 (patch) | |
| tree | fbf40682ac5a2d61f70c5a944894b6311ac530bf | |
| parent | 0cba8dd69156eab50142efe67f4f3fac22a08081 (diff) | |
Show the version number during update process.
Number is stored inside the data/last_update.txt file and shown if there
is an update script.
See https://github.com/FreshRSS/FreshRSS/issues/699
| -rw-r--r-- | app/Controllers/updateController.php | 17 | ||||
| -rw-r--r-- | app/i18n/en/feedback.php | 2 | ||||
| -rw-r--r-- | app/i18n/fr/feedback.php | 2 |
3 files changed, 13 insertions, 8 deletions
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php index 1b44a739c..4bdd96f6d 100644 --- a/app/Controllers/updateController.php +++ b/app/Controllers/updateController.php @@ -1,8 +1,8 @@ <?php class FreshRSS_update_Controller extends Minz_ActionController { + public function firstAction() { - $current_user = Minz_Session::param('currentUser', ''); if (!FreshRSS_Auth::hasAccess('admin')) { Minz_Error::error(403); } @@ -12,8 +12,8 @@ class FreshRSS_update_Controller extends Minz_ActionController { $this->view->update_to_apply = false; $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) { + $timestamp = @filemtime(join_path(DATA_PATH, 'last_update.txt')); + if ($timestamp !== false) { $this->view->last_update_time = timestamptodate($timestamp); $this->view->check_last_hour = (time() - 3600) <= $timestamp; } @@ -30,11 +30,12 @@ class FreshRSS_update_Controller extends Minz_ActionController { ); } elseif (file_exists(UPDATE_FILENAME)) { // There is an update file to apply! + $version = file_get_contents(join_path(DATA_PATH, 'last_update.txt')); $this->view->update_to_apply = true; $this->view->message = array( 'status' => 'good', 'title' => _t('gen.short.ok'), - 'body' => _t('feedback.update.can_apply') + 'body' => _t('feedback.update.can_apply', $version) ); } } @@ -82,13 +83,17 @@ class FreshRSS_update_Controller extends Minz_ActionController { 'body' => _t('feedback.update.none') ); - @file_put_contents(DATA_PATH . '/last_update.txt', time()); + @touch(join_path(DATA_PATH, 'last_update.txt')); return; } $script = $res_array[1]; if (file_put_contents(UPDATE_FILENAME, $script) !== false) { + $version = explode(' ', $status, 2); + $version = $version[1]; + @file_put_contents(join_path(DATA_PATH, 'last_update.txt'), $version); + Minz_Request::forward(array('c' => 'update')); } else { $this->view->message = array( @@ -111,7 +116,7 @@ class FreshRSS_update_Controller extends Minz_ActionController { if ($res === true) { @unlink(UPDATE_FILENAME); - @file_put_contents(DATA_PATH . '/last_update.txt', time()); + @file_put_contents(join_path(DATA_PATH, 'last_update.txt'), ''); Minz_Request::good(_t('feedback.update.finished')); } else { Minz_Request::bad(_t('feedback.update.error', $res), diff --git a/app/i18n/en/feedback.php b/app/i18n/en/feedback.php index 5f7183da3..e9499ed46 100644 --- a/app/i18n/en/feedback.php +++ b/app/i18n/en/feedback.php @@ -80,7 +80,7 @@ return array( 'purge_completed' => 'Purge completed (%d articles deleted)', ), 'update' => array( - 'can_apply' => 'An update is available.', + 'can_apply' => 'FreshRSS will be now updated to the <strong>version %s</strong>.', 'error' => 'The update process has encountered an error: %s', 'file_is_nok' => 'Check permissions on <em>%s</em> directory. HTTP server must have rights to write into', 'finished' => 'Update completed!', diff --git a/app/i18n/fr/feedback.php b/app/i18n/fr/feedback.php index 5c71bbae1..c99314411 100644 --- a/app/i18n/fr/feedback.php +++ b/app/i18n/fr/feedback.php @@ -80,7 +80,7 @@ return array( 'purge_completed' => 'Purge effectuée (%d articles supprimés).', ), 'update' => array( - 'can_apply' => 'Une mise à jour est disponible.', + 'can_apply' => 'FreshRSS va maintenant être mis à jour vers la <strong>version %s</strong>.', 'error' => 'La mise à jour a rencontré un problème : %s', 'file_is_nok' => 'Veuillez vérifier les droits sur le répertoire <em>%s</em>. Le serveur HTTP doit être capable d’écrire dedans', 'finished' => 'La mise à jour est terminée !', |
