Skip to content

Commit 9486dbb

Browse files
authored
Merge pull request #1500 from nextcloud/stable10-backport-1499
[stable10] Add repair step and revert "Open updater" button
2 parents e0dd676 + a39d5ca commit 9486dbb

File tree

9 files changed

+111
-14
lines changed

9 files changed

+111
-14
lines changed

apps/updatenotification/js/admin.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,33 @@
1313
/**
1414
* Creates a new authentication token and loads the updater URL
1515
*/
16+
var loginToken = '';
1617
$(document).ready(function(){
18+
$('#oca_updatenotification_button').click(function() {
19+
// Load the new token
20+
$.ajax({
21+
url: OC.generateUrl('/apps/updatenotification/credentials')
22+
}).success(function(data) {
23+
loginToken = data;
24+
$.ajax({
25+
url: OC.webroot+'/updater/',
26+
headers: {
27+
'X-Updater-Auth': loginToken
28+
},
29+
method: 'POST',
30+
success: function(data){
31+
if(data !== 'false') {
32+
var body = $('body');
33+
$('head').remove();
34+
body.html(data);
35+
body.removeAttr('id');
36+
body.attr('id', 'body-settings');
37+
}
38+
}
39+
});
40+
});
41+
});
42+
1743
$('#release-channel').change(function() {
1844
var newChannel = $('#release-channel').find(":selected").val();
1945

apps/updatenotification/lib/Controller/AdminController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ public function displayPanel() {
112112
'currentChannel' => $currentChannel,
113113
'channels' => $channels,
114114
'newVersionString' => ($updateState === []) ? '' : $updateState['updateVersion'],
115-
'downloadLink' => (empty($updateState['downloadLink'])) ? '' : $updateState['downloadLink'],
116115

117116
'notify_groups' => implode('|', $notifyGroups),
118117
];

apps/updatenotification/lib/UpdateChecker.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ public function getUpdateState() {
4949
if(substr($data['web'], 0, 8) === 'https://') {
5050
$result['updateLink'] = $data['web'];
5151
}
52-
if(substr($data['url'], 0, 8) === 'https://') {
53-
$result['downloadLink'] = $data['url'];
54-
}
5552

5653
return $result;
5754
}

apps/updatenotification/templates/admin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
<form id="oca_updatenotification_section" class="followupsection">
1717
<?php if($isNewVersionAvailable === true): ?>
1818
<strong><?php p($l->t('A new version is available: %s', [$newVersionString])); ?></strong>
19-
<?php if ($_['downloadLink']): ?>
20-
<a href="<?php p($_['downloadLink']); ?>" class="button"><?php p($l->t('Download now')) ?></a>
21-
<?php endif; ?>
19+
<input type="button" id="oca_updatenotification_button" value="<?php p($l->t('Open updater')) ?>">
2220
<?php else: ?>
2321
<strong><?php print_unescaped($l->t('Your version is up to date.')); ?></strong>
2422
<span class="icon-info svg" title="<?php p($l->t('Checked on %s', [$lastCheckedDate])) ?>"></span>

apps/updatenotification/tests/Controller/AdminControllerTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ public function testDisplayPanelWithUpdate() {
110110
$this->updateChecker
111111
->expects($this->once())
112112
->method('getUpdateState')
113-
->willReturn([
114-
'updateVersion' => '8.1.2',
115-
'downloadLink' => 'https://downloads.nextcloud.org/server',
116-
]);
113+
->willReturn(['updateVersion' => '8.1.2']);
117114

118115
$params = [
119116
'isNewVersionAvailable' => true,
@@ -122,7 +119,6 @@ public function testDisplayPanelWithUpdate() {
122119
'channels' => $channels,
123120
'newVersionString' => '8.1.2',
124121
'notify_groups' => 'admin',
125-
'downloadLink' => 'https://downloads.nextcloud.org/server',
126122
];
127123

128124
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
@@ -167,7 +163,6 @@ public function testDisplayPanelWithoutUpdate() {
167163
'channels' => $channels,
168164
'newVersionString' => '',
169165
'notify_groups' => 'admin',
170-
'downloadLink' => '',
171166
];
172167

173168
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');

apps/updatenotification/tests/UpdateCheckerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public function testGetUpdateStateWithUpdateAndValidLink() {
7474
'updateAvailable' => true,
7575
'updateVersion' => 'Nextcloud 123',
7676
'updateLink' => 'https://docs.nextcloud.com/myUrl',
77-
'downloadLink' => 'https://downloads.nextcloud.org/server',
7877
];
7978
$this->assertSame($expected, $this->updateChecker->getUpdateState());
8079
}

lib/private/Repair.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use OC\Repair\CleanTags;
3636
use OC\Repair\Collation;
3737
use OC\Repair\DropOldJobs;
38+
use OC\Repair\MoveUpdaterStepFile;
3839
use OC\Repair\OldGroupMembershipShares;
3940
use OC\Repair\RemoveGetETagEntries;
4041
use OC\Repair\RemoveOldShares;
@@ -147,6 +148,7 @@ public static function getRepairSteps() {
147148
\OC::$server->getUserManager(),
148149
\OC::$server->getGroupManager()
149150
),
151+
new MoveUpdaterStepFile(\OC::$server->getConfig()),
150152
];
151153
}
152154

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2016 Morris Jobke <[email protected]>
4+
*
5+
* @author Morris Jobke <[email protected]>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
namespace OC\Repair;
25+
26+
use OCP\Migration\IOutput;
27+
use OCP\Migration\IRepairStep;
28+
29+
class MoveUpdaterStepFile implements IRepairStep {
30+
31+
/** @var \OCP\IConfig */
32+
protected $config;
33+
34+
/**
35+
* @param \OCP\IConfig $config
36+
*/
37+
public function __construct($config) {
38+
$this->config = $config;
39+
}
40+
41+
public function getName() {
42+
return 'Move .step file of updater to backup location';
43+
}
44+
45+
public function run(IOutput $output) {
46+
47+
$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT);
48+
$instanceId = $this->config->getSystemValue('instanceid', null);
49+
50+
if(!is_string($instanceId) || empty($instanceId)) {
51+
return;
52+
}
53+
54+
$updaterFolderPath = $dataDir . '/updater-' . $instanceId;
55+
$stepFile = $updaterFolderPath . '/.step';
56+
if(file_exists($stepFile)) {
57+
$output->info('.step file exists');
58+
59+
$previousStepFile = $updaterFolderPath . '/.step-previous-update';
60+
61+
// cleanup
62+
if(file_exists($previousStepFile)) {
63+
if(\OC_Helper::rmdirr($previousStepFile)) {
64+
$output->info('.step-previous-update removed');
65+
} else {
66+
$output->info('.step-previous-update can\'t be removed - abort move of .step file');
67+
return;
68+
}
69+
}
70+
71+
// move step file
72+
if(rename($stepFile, $previousStepFile)) {
73+
$output->info('.step file moved to .step-previous-update');
74+
} else {
75+
$output->warning('.step file can\'t be moved');
76+
}
77+
}
78+
}
79+
}
80+

lib/public/Util.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public static function setChannel($channel) {
8585
//Flush timestamp to reload version.php
8686
\OC::$server->getSession()->set('OC_Version_Timestamp', 0);
8787
\OC::$server->getAppConfig()->setValue('core', 'OC_Channel', $channel);
88+
\OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel);
8889
}
8990

9091
/**

0 commit comments

Comments
 (0)