Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/updatenotification/controller/admincontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ public function displayPanel() {
'channels' => $channels,
'newVersionString' => ($updateState === []) ? '' : $updateState['updateVersion'],
'updaterRequirementsFulfilled' => $this->isCompatibleWithUpdater(),
'downloadLink' => (empty($updateState['downloadLink'])) ? '' : $updateState['downloadLink'],
];

return new TemplateResponse($this->appName, 'admin', $params, '');
Expand Down
25 changes: 25 additions & 0 deletions apps/updatenotification/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,32 @@
/**
* Creates a new authentication token and loads the updater URL
*/
var loginToken = '';
$(document).ready(function(){
$('#oca_updatenotification_button').click(function() {
// Load the new token
$.ajax({
url: OC.generateUrl('/apps/updatenotification/credentials')
}).success(function(data) {
loginToken = data;
$.ajax({
url: OC.webroot+'/updater/',
headers: {
'X-Updater-Auth': loginToken
},
method: 'POST',
success: function(data){
if(data !== 'false') {
var body = $('body');
$('head').remove();
body.html(data);
body.removeAttr('id');
body.attr('id', 'body-settings');
}
}
});
});
});
$('#release-channel').change(function() {
var newChannel = $('#release-channel').find(":selected").val();
$.post(
Expand Down
3 changes: 0 additions & 3 deletions apps/updatenotification/lib/updatechecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public function getUpdateState() {
if(substr($data['web'], 0, 8) === 'https://') {
$result['updateLink'] = $data['web'];
}
if(substr($data['url'], 0, 8) === 'https://') {
$result['downloadLink'] = $data['url'];
}

return $result;
}
Expand Down
6 changes: 4 additions & 2 deletions apps/updatenotification/templates/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

<?php if($isNewVersionAvailable === true): ?>
<strong><?php p($l->t('A new version is available: %s', [$newVersionString])); ?></strong>
<?php if ($_['downloadLink']): ?>
<a href="<?php p($_['downloadLink']); ?>" class="button"><?php p($l->t('Download now')) ?></a>
<?php if($updaterRequirementsFulfilled === true): ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we remove that as well now? :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on master only?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. This is also not on master. (no idea how this came in here)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah gotcha ... it was only added in stable9.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this.

<input type="button" id="oca_updatenotification_button" value="<?php p($l->t('Open updater')) ?>">
<?php else: ?>
<br/><?php p($l->t('At the moment only manual updates are supported on your environment. This is very likely the case because functions such as shell_exec are not available.')); ?>
<?php endif; ?>
<?php else: ?>
<strong><?php print_unescaped($l->t('Your version is up to date.')); ?></strong>
Expand Down
15 changes: 6 additions & 9 deletions apps/updatenotification/tests/UpdateCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ public function testGetUpdateStateWithUpdateAndInvalidLink() {
->method('check')
->willReturn([
'version' => 123,
'versionstring' => 'Nextcloud 123',
'versionstring' => 'ownCloud 123',
'web'=> 'javascript:alert(1)',
'url'=> 'javascript:alert(2)',
]);

$expected = [
'updateAvailable' => true,
'updateVersion' => 'Nextcloud 123',
'updateVersion' => 'ownCloud 123',
];
$this->assertSame($expected, $this->updateChecker->getUpdateState());
}
Expand All @@ -64,16 +63,14 @@ public function testGetUpdateStateWithUpdateAndValidLink() {
->method('check')
->willReturn([
'version' => 123,
'versionstring' => 'Nextcloud 123',
'web'=> 'https://docs.nextcloud.com/myUrl',
'url'=> 'https://downloads.nextcloud.org/server',
'versionstring' => 'ownCloud 123',
'web'=> 'https://owncloud.org/myUrl',
]);

$expected = [
'updateAvailable' => true,
'updateVersion' => 'Nextcloud 123',
'updateLink' => 'https://docs.nextcloud.com/myUrl',
'downloadLink' => 'https://downloads.nextcloud.org/server',
'updateVersion' => 'ownCloud 123',
'updateLink' => 'https://owncloud.org/myUrl',
];
$this->assertSame($expected, $this->updateChecker->getUpdateState());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public function testDisplayPanelWithUpdate() {
'channels' => $channels,
'newVersionString' => '8.1.2',
'updaterRequirementsFulfilled' => true,
'downloadLink' => '',
];

$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
Expand Down Expand Up @@ -161,10 +160,7 @@ public function testDisplayPanelWithUpdateAndIncompatibleUpdaterApp() {
$this->updateChecker
->expects($this->once())
->method('getUpdateState')
->willReturn([
'updateVersion' => '8.1.2',
'downloadLink' => 'https://downloads.nextcloud.org/server',
]);
->willReturn(['updateVersion' => '8.1.2']);
$this->adminController
->expects($this->once())
->method('isCompatibleWithUpdater')
Expand All @@ -177,7 +173,6 @@ public function testDisplayPanelWithUpdateAndIncompatibleUpdaterApp() {
'channels' => $channels,
'newVersionString' => '8.1.2',
'updaterRequirementsFulfilled' => false,
'downloadLink' => 'https://downloads.nextcloud.org/server',
];

$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
Expand Down Expand Up @@ -224,7 +219,6 @@ public function testDisplayPanelWithoutUpdate() {
'channels' => $channels,
'newVersionString' => '',
'updaterRequirementsFulfilled' => true,
'downloadLink' => '',
];

$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
Expand Down
2 changes: 2 additions & 0 deletions lib/private/repair.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use OC\Repair\DropOldJobs;
use OC\Repair\EncryptionCompatibility;
use OC\Repair\MoveChannelToSystemConfig;
use OC\Repair\MoveUpdaterStepFile;
use OC\Repair\OldGroupMembershipShares;
use OC\Repair\RemoveGetETagEntries;
use OC\Repair\SqliteAutoincrement;
Expand Down Expand Up @@ -123,6 +124,7 @@ public static function getRepairSteps() {
new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
new AvatarPermissions(\OC::$server->getDatabaseConnection()),
new MoveChannelToSystemConfig(\OC::$server->getConfig()),
new MoveUpdaterStepFile(\OC::$server->getConfig()),
];
}

Expand Down
81 changes: 81 additions & 0 deletions lib/private/repair/moveupdaterstepfile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/**
* @copyright Copyright (c) 2016 Morris Jobke <[email protected]>
*
* @author Morris Jobke <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OC\Repair;

use OC\Hooks\BasicEmitter;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

class MoveUpdaterStepFile extends BasicEmitter implements \OC\RepairStep {

/** @var \OCP\IConfig */
protected $config;

/**
* @param \OCP\IConfig $config
*/
public function __construct($config) {
$this->config = $config;
}

public function getName() {
return 'Move .step file of updater to backup location';
}

public function run() {

$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT);
$instanceId = $this->config->getSystemValue('instanceid', null);

if(!is_string($instanceId) || empty($instanceId)) {
return;
}

$updaterFolderPath = $dataDir . '/updater-' . $instanceId;
$stepFile = $updaterFolderPath . '/.step';
if(file_exists($stepFile)) {
$this->emit('\OC\Repair', 'info', array('.step file exists'));

$previousStepFile = $updaterFolderPath . '/.step-previous-update';

// cleanup
if(file_exists($previousStepFile)) {
if(\OC_Helper::rmdirr($previousStepFile)) {
$this->emit('\OC\Repair', 'info', array('.step-previous-update removed'));
} else {
$this->emit('\OC\Repair', 'info', array('.step-previous-update can\'t be removed - abort move of .step file'));
return;
}
}

// move step file
if(rename($stepFile, $previousStepFile)) {
$this->emit('\OC\Repair', 'info', array('.step file moved to .step-previous-update'));
} else {
$this->emit('\OC\Repair', 'warning', array('.step file can\'t be moved'));
}
}
}
}