Merge branch 'master' into fix-db-locking-cleanup
This commit is contained in:
commit
7a0720f300
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
namespace OCA\Files_External\Config;
|
namespace OCA\Files_External\Config;
|
||||||
|
|
||||||
|
use OC\Files\Storage\Wrapper\Availability;
|
||||||
use OCA\Files_external\Migration\StorageMigrator;
|
use OCA\Files_external\Migration\StorageMigrator;
|
||||||
use OCP\Files\Storage;
|
use OCP\Files\Storage;
|
||||||
use OC\Files\Mount\MountPoint;
|
use OC\Files\Mount\MountPoint;
|
||||||
|
@ -34,6 +35,7 @@ use OCA\Files_external\Service\UserStoragesService;
|
||||||
use OCA\Files_External\Service\UserGlobalStoragesService;
|
use OCA\Files_External\Service\UserGlobalStoragesService;
|
||||||
use OCA\Files_External\Lib\StorageConfig;
|
use OCA\Files_External\Lib\StorageConfig;
|
||||||
use OCA\Files_External\Lib\FailedStorage;
|
use OCA\Files_External\Lib\FailedStorage;
|
||||||
|
use OCP\Files\StorageNotAvailableException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the old files_external config work with the new public mount config api
|
* Make the old files_external config work with the new public mount config api
|
||||||
|
@ -132,8 +134,10 @@ class ConfigAdapter implements IMountProvider {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$availability = $impl->getAvailability();
|
$availability = $impl->getAvailability();
|
||||||
if (!$availability['available']) {
|
if (!$availability['available'] && !Availability::shouldRecheck($availability)) {
|
||||||
$impl = new FailedStorage(['exception' => null]);
|
$impl = new FailedStorage([
|
||||||
|
'exception' => new StorageNotAvailableException('Storage with mount id ' . $storage->getId() . ' is not available')
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// propagate exception into filesystem
|
// propagate exception into filesystem
|
||||||
|
|
|
@ -39,6 +39,9 @@ class FailedStorage extends Common {
|
||||||
*/
|
*/
|
||||||
public function __construct($params) {
|
public function __construct($params) {
|
||||||
$this->e = $params['exception'];
|
$this->e = $params['exception'];
|
||||||
|
if (!$this->e) {
|
||||||
|
throw new \InvalidArgumentException('Missing "exception" argument in FailedStorage constructor');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId() {
|
public function getId() {
|
||||||
|
|
|
@ -204,7 +204,7 @@ class Trashbin {
|
||||||
|
|
||||||
$ownerView = new View('/' . $owner);
|
$ownerView = new View('/' . $owner);
|
||||||
// file has been deleted in between
|
// file has been deleted in between
|
||||||
if (!$ownerView->file_exists('/files/' . $ownerPath)) {
|
if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/' . $ownerPath)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,11 @@ if(\OC::$server->getConfig()->getSystemValue('updatechecker', true) === true) {
|
||||||
|
|
||||||
$userObject = \OC::$server->getUserSession()->getUser();
|
$userObject = \OC::$server->getUserSession()->getUser();
|
||||||
if($userObject !== null) {
|
if($userObject !== null) {
|
||||||
if(\OC::$server->getGroupManager()->isAdmin($userObject->getUID()) && $updateChecker->getUpdateState() !== []) {
|
if(\OC::$server->getGroupManager()->isAdmin($userObject->getUID())) {
|
||||||
|
if($updateChecker->getUpdateState() !== []) {
|
||||||
\OCP\Util::addScript('updatenotification', 'notification');
|
\OCP\Util::addScript('updatenotification', 'notification');
|
||||||
OC_Hook::connect('\OCP\Config', 'js', $updateChecker, 'getJavaScript');
|
OC_Hook::connect('\OCP\Config', 'js', $updateChecker, 'getJavaScript');
|
||||||
|
}
|
||||||
\OC_App::registerAdmin('updatenotification', 'admin');
|
\OC_App::registerAdmin('updatenotification', 'admin');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
namespace OCA\UpdateNotification\AppInfo;
|
namespace OCA\UpdateNotification\AppInfo;
|
||||||
|
|
||||||
use OC\AppFramework\Utility\TimeFactory;
|
use OC\AppFramework\Utility\TimeFactory;
|
||||||
|
use OC\Updater;
|
||||||
use OCA\UpdateNotification\Controller\AdminController;
|
use OCA\UpdateNotification\Controller\AdminController;
|
||||||
|
use OCA\UpdateNotification\UpdateChecker;
|
||||||
use OCP\AppFramework\App;
|
use OCP\AppFramework\App;
|
||||||
use OCP\AppFramework\IAppContainer;
|
use OCP\AppFramework\IAppContainer;
|
||||||
|
|
||||||
|
@ -32,13 +34,21 @@ class Application extends App {
|
||||||
$container = $this->getContainer();
|
$container = $this->getContainer();
|
||||||
|
|
||||||
$container->registerService('AdminController', function(IAppContainer $c) {
|
$container->registerService('AdminController', function(IAppContainer $c) {
|
||||||
|
$updater = new \OC\Updater(
|
||||||
|
\OC::$server->getHTTPHelper(),
|
||||||
|
\OC::$server->getConfig(),
|
||||||
|
\OC::$server->getIntegrityCodeChecker()
|
||||||
|
);
|
||||||
return new AdminController(
|
return new AdminController(
|
||||||
$c->query('AppName'),
|
$c->query('AppName'),
|
||||||
$c->query('Request'),
|
$c->query('Request'),
|
||||||
$c->getServer()->getJobList(),
|
$c->getServer()->getJobList(),
|
||||||
$c->getServer()->getSecureRandom(),
|
$c->getServer()->getSecureRandom(),
|
||||||
$c->getServer()->getConfig(),
|
$c->getServer()->getConfig(),
|
||||||
new TimeFactory()
|
new TimeFactory(),
|
||||||
|
$c->getServer()->getL10N($c->query('AppName')),
|
||||||
|
new UpdateChecker($updater),
|
||||||
|
$c->getServer()->getDateTimeFormatter()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,4 +24,5 @@ namespace OCA\UpdateNotification\AppInfo;
|
||||||
$application = new Application();
|
$application = new Application();
|
||||||
$application->registerRoutes($this, ['routes' => [
|
$application->registerRoutes($this, ['routes' => [
|
||||||
['name' => 'Admin#createCredentials', 'url' => '/credentials', 'verb' => 'GET'],
|
['name' => 'Admin#createCredentials', 'url' => '/credentials', 'verb' => 'GET'],
|
||||||
|
['name' => 'Admin#setChannel', 'url' => '/channel', 'verb' => 'POST'],
|
||||||
]]);
|
]]);
|
||||||
|
|
|
@ -21,12 +21,15 @@
|
||||||
|
|
||||||
namespace OCA\UpdateNotification\Controller;
|
namespace OCA\UpdateNotification\Controller;
|
||||||
|
|
||||||
|
use OCA\UpdateNotification\UpdateChecker;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\AppFramework\Utility\ITimeFactory;
|
use OCP\AppFramework\Utility\ITimeFactory;
|
||||||
use OCP\BackgroundJob\IJobList;
|
use OCP\BackgroundJob\IJobList;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
use OCP\IDateTimeFormatter;
|
||||||
|
use OCP\IL10N;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\Security\ISecureRandom;
|
use OCP\Security\ISecureRandom;
|
||||||
|
|
||||||
|
@ -39,6 +42,12 @@ class AdminController extends Controller {
|
||||||
private $config;
|
private $config;
|
||||||
/** @var ITimeFactory */
|
/** @var ITimeFactory */
|
||||||
private $timeFactory;
|
private $timeFactory;
|
||||||
|
/** @var UpdateChecker */
|
||||||
|
private $updateChecker;
|
||||||
|
/** @var IL10N */
|
||||||
|
private $l10n;
|
||||||
|
/** @var IDateTimeFormatter */
|
||||||
|
private $dateTimeFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $appName
|
* @param string $appName
|
||||||
|
@ -47,25 +56,70 @@ class AdminController extends Controller {
|
||||||
* @param ISecureRandom $secureRandom
|
* @param ISecureRandom $secureRandom
|
||||||
* @param IConfig $config
|
* @param IConfig $config
|
||||||
* @param ITimeFactory $timeFactory
|
* @param ITimeFactory $timeFactory
|
||||||
|
* @param IL10N $l10n
|
||||||
|
* @param UpdateChecker $updateChecker
|
||||||
|
* @param IDateTimeFormatter $dateTimeFormatter
|
||||||
*/
|
*/
|
||||||
public function __construct($appName,
|
public function __construct($appName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
IJobList $jobList,
|
IJobList $jobList,
|
||||||
ISecureRandom $secureRandom,
|
ISecureRandom $secureRandom,
|
||||||
IConfig $config,
|
IConfig $config,
|
||||||
ITimeFactory $timeFactory) {
|
ITimeFactory $timeFactory,
|
||||||
|
IL10N $l10n,
|
||||||
|
UpdateChecker $updateChecker,
|
||||||
|
IDateTimeFormatter $dateTimeFormatter) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->jobList = $jobList;
|
$this->jobList = $jobList;
|
||||||
$this->secureRandom = $secureRandom;
|
$this->secureRandom = $secureRandom;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->timeFactory = $timeFactory;
|
$this->timeFactory = $timeFactory;
|
||||||
|
$this->l10n = $l10n;
|
||||||
|
$this->updateChecker = $updateChecker;
|
||||||
|
$this->dateTimeFormatter = $dateTimeFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TemplateResponse
|
* @return TemplateResponse
|
||||||
*/
|
*/
|
||||||
public function displayPanel() {
|
public function displayPanel() {
|
||||||
return new TemplateResponse($this->appName, 'admin', [], '');
|
$lastUpdateCheck = $this->dateTimeFormatter->formatDateTime(
|
||||||
|
$this->config->getAppValue('core', 'lastupdatedat')
|
||||||
|
);
|
||||||
|
|
||||||
|
$channels = [
|
||||||
|
'daily',
|
||||||
|
'beta',
|
||||||
|
'stable',
|
||||||
|
'production',
|
||||||
|
];
|
||||||
|
$currentChannel = \OCP\Util::getChannel();
|
||||||
|
|
||||||
|
// Remove the currently used channel from the channels list
|
||||||
|
if(($key = array_search($currentChannel, $channels)) !== false) {
|
||||||
|
unset($channels[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'isNewVersionAvailable' => ($this->updateChecker->getUpdateState() === []) ? false : true,
|
||||||
|
'lastChecked' => $lastUpdateCheck,
|
||||||
|
'currentChannel' => $currentChannel,
|
||||||
|
'channels' => $channels,
|
||||||
|
];
|
||||||
|
|
||||||
|
return new TemplateResponse($this->appName, 'admin', $params, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @UseSession
|
||||||
|
*
|
||||||
|
* @param string $channel
|
||||||
|
* @return DataResponse
|
||||||
|
*/
|
||||||
|
public function setChannel($channel) {
|
||||||
|
\OCP\Util::setChannel($channel);
|
||||||
|
$this->config->setAppValue('core', 'lastupdatedat', 0);
|
||||||
|
return new DataResponse(['status' => 'success', 'data' => ['message' => $this->l10n->t('Updated channel')]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
var loginToken = '';
|
var loginToken = '';
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('#oca_updatenotification').click(function() {
|
$('#oca_updatenotification_button').click(function() {
|
||||||
// Load the new token
|
// Load the new token
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: OC.generateUrl('/apps/updatenotification/credentials')
|
url: OC.generateUrl('/apps/updatenotification/credentials')
|
||||||
|
@ -39,4 +39,16 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
$('#release-channel').change(function() {
|
||||||
|
var newChannel = $('#release-channel').find(":selected").val();
|
||||||
|
$.post(
|
||||||
|
OC.generateUrl('/apps/updatenotification/channel'),
|
||||||
|
{
|
||||||
|
'channel': newChannel
|
||||||
|
},
|
||||||
|
function(data){
|
||||||
|
OC.msg.finishedAction('#channel_save_msg', data);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,42 @@
|
||||||
<?php script('updatenotification', 'admin') ?>
|
<?php
|
||||||
<form id="oca_updatenotification" class="section">
|
script('updatenotification', 'admin');
|
||||||
|
|
||||||
|
/** @var array $_ */
|
||||||
|
/** @var bool $isNewVersionAvailable */
|
||||||
|
$isNewVersionAvailable = $_['isNewVersionAvailable'];
|
||||||
|
/** @var string $newVersionString */
|
||||||
|
$newVersionString = $_['newVersionString'];
|
||||||
|
/** @var string $lastCheckedDate */
|
||||||
|
$lastCheckedDate = $_['lastChecked'];
|
||||||
|
/** @var array $channels */
|
||||||
|
$channels = $_['channels'];
|
||||||
|
/** @var string $currentChannel */
|
||||||
|
$currentChannel = $_['currentChannel'];
|
||||||
|
?>
|
||||||
|
<form id="oca_updatenotification_section" class="section">
|
||||||
<h2><?php p($l->t('Updater')); ?></h2>
|
<h2><?php p($l->t('Updater')); ?></h2>
|
||||||
|
|
||||||
|
<?php if($isNewVersionAvailable === true): ?>
|
||||||
|
<strong><?php p($l->t('A new version is available: %s', [$newVersionString])); ?></strong>
|
||||||
|
<input type="button" id="oca_updatenotification_button" value="<?php p($l->t('Open updater')) ?>">
|
||||||
|
<?php else: ?>
|
||||||
|
<strong><?php print_unescaped($l->t('Your version is up to date.')); ?></strong>
|
||||||
|
<span class="icon-info svg" title="<?php p($l->t('Checked on %s', [$lastCheckedDate])) ?>"></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?php p($l->t('For security reasons the built-in ownCloud updater is using additional credentials. To visit the updater page please click the following button.')) ?>
|
<label for="release-channel"><?php p($l->t('Update channel:')) ?></label>
|
||||||
|
<select id="release-channel">
|
||||||
|
<option value="<?php p($currentChannel); ?>"><?php p($currentChannel); ?></option>
|
||||||
|
<?php foreach ($channels as $channel => $channelTitle){ ?>
|
||||||
|
<option value="<?php p($channelTitle) ?>">
|
||||||
|
<?php p($channelTitle) ?>
|
||||||
|
</option>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
|
<span id="channel_save_msg"></span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<em><?php p($l->t('You can always update to a newer version / experimental channel. But you can never downgrade to a more stable channel.')); ?></em>
|
||||||
</p>
|
</p>
|
||||||
<input type="button" id="oca_updatenotification" value="<?php p($l->t('Open updater')) ?>">
|
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -22,11 +22,14 @@
|
||||||
namespace OCA\UpdateNotification\Tests\Controller;
|
namespace OCA\UpdateNotification\Tests\Controller;
|
||||||
|
|
||||||
use OCA\UpdateNotification\Controller\AdminController;
|
use OCA\UpdateNotification\Controller\AdminController;
|
||||||
|
use OCA\UpdateNotification\UpdateChecker;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\AppFramework\Utility\ITimeFactory;
|
use OCP\AppFramework\Utility\ITimeFactory;
|
||||||
use OCP\BackgroundJob\IJobList;
|
use OCP\BackgroundJob\IJobList;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
use OCP\IDateTimeFormatter;
|
||||||
|
use OCP\IL10N;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\Security\ISecureRandom;
|
use OCP\Security\ISecureRandom;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
@ -44,6 +47,12 @@ class AdminControllerTest extends TestCase {
|
||||||
private $adminController;
|
private $adminController;
|
||||||
/** @var ITimeFactory */
|
/** @var ITimeFactory */
|
||||||
private $timeFactory;
|
private $timeFactory;
|
||||||
|
/** @var IL10N */
|
||||||
|
private $l10n;
|
||||||
|
/** @var UpdateChecker */
|
||||||
|
private $updateChecker;
|
||||||
|
/** @var IDateTimeFormatter */
|
||||||
|
private $dateTimeFormatter;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -53,6 +62,10 @@ class AdminControllerTest extends TestCase {
|
||||||
$this->secureRandom = $this->getMock('\\OCP\\Security\\ISecureRandom');
|
$this->secureRandom = $this->getMock('\\OCP\\Security\\ISecureRandom');
|
||||||
$this->config = $this->getMock('\\OCP\\IConfig');
|
$this->config = $this->getMock('\\OCP\\IConfig');
|
||||||
$this->timeFactory = $this->getMock('\\OCP\\AppFramework\\Utility\\ITimeFactory');
|
$this->timeFactory = $this->getMock('\\OCP\\AppFramework\\Utility\\ITimeFactory');
|
||||||
|
$this->l10n = $this->getMock('\\OCP\\IL10N');
|
||||||
|
$this->updateChecker = $this->getMockBuilder('\\OCA\\UpdateNotification\\UpdateChecker')
|
||||||
|
->disableOriginalConstructor()->getMock();
|
||||||
|
$this->dateTimeFormatter = $this->getMock('\\OCP\\IDateTimeFormatter');
|
||||||
|
|
||||||
$this->adminController = new AdminController(
|
$this->adminController = new AdminController(
|
||||||
'updatenotification',
|
'updatenotification',
|
||||||
|
@ -60,15 +73,94 @@ class AdminControllerTest extends TestCase {
|
||||||
$this->jobList,
|
$this->jobList,
|
||||||
$this->secureRandom,
|
$this->secureRandom,
|
||||||
$this->config,
|
$this->config,
|
||||||
$this->timeFactory
|
$this->timeFactory,
|
||||||
|
$this->l10n,
|
||||||
|
$this->updateChecker,
|
||||||
|
$this->dateTimeFormatter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDisplayPanel() {
|
public function testDisplayPanelWithUpdate() {
|
||||||
$expected = new TemplateResponse('updatenotification', 'admin', [], '');
|
$channels = [
|
||||||
|
'daily',
|
||||||
|
'beta',
|
||||||
|
'stable',
|
||||||
|
'production',
|
||||||
|
];
|
||||||
|
$currentChannel = \OCP\Util::getChannel();
|
||||||
|
|
||||||
|
// Remove the currently used channel from the channels list
|
||||||
|
if(($key = array_search($currentChannel, $channels)) !== false) {
|
||||||
|
unset($channels[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->config
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getAppValue')
|
||||||
|
->with('core', 'lastupdatedat')
|
||||||
|
->willReturn('12345');
|
||||||
|
$this->dateTimeFormatter
|
||||||
|
->expects($this->once())
|
||||||
|
->method('formatDateTime')
|
||||||
|
->with('12345')
|
||||||
|
->willReturn('LastCheckedReturnValue');
|
||||||
|
$this->updateChecker
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getUpdateState')
|
||||||
|
->willReturn(['foo' => 'bar']);
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'isNewVersionAvailable' => true,
|
||||||
|
'lastChecked' => 'LastCheckedReturnValue',
|
||||||
|
'currentChannel' => \OCP\Util::getChannel(),
|
||||||
|
'channels' => $channels,
|
||||||
|
];
|
||||||
|
|
||||||
|
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
|
||||||
$this->assertEquals($expected, $this->adminController->displayPanel());
|
$this->assertEquals($expected, $this->adminController->displayPanel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDisplayPanelWithoutUpdate() {
|
||||||
|
$channels = [
|
||||||
|
'daily',
|
||||||
|
'beta',
|
||||||
|
'stable',
|
||||||
|
'production',
|
||||||
|
];
|
||||||
|
$currentChannel = \OCP\Util::getChannel();
|
||||||
|
|
||||||
|
// Remove the currently used channel from the channels list
|
||||||
|
if(($key = array_search($currentChannel, $channels)) !== false) {
|
||||||
|
unset($channels[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->config
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getAppValue')
|
||||||
|
->with('core', 'lastupdatedat')
|
||||||
|
->willReturn('12345');
|
||||||
|
$this->dateTimeFormatter
|
||||||
|
->expects($this->once())
|
||||||
|
->method('formatDateTime')
|
||||||
|
->with('12345')
|
||||||
|
->willReturn('LastCheckedReturnValue');
|
||||||
|
$this->updateChecker
|
||||||
|
->expects($this->once())
|
||||||
|
->method('getUpdateState')
|
||||||
|
->willReturn([]);
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'isNewVersionAvailable' => false,
|
||||||
|
'lastChecked' => 'LastCheckedReturnValue',
|
||||||
|
'currentChannel' => \OCP\Util::getChannel(),
|
||||||
|
'channels' => $channels,
|
||||||
|
];
|
||||||
|
|
||||||
|
$expected = new TemplateResponse('updatenotification', 'admin', $params, '');
|
||||||
|
$this->assertEquals($expected, $this->adminController->displayPanel());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testCreateCredentials() {
|
public function testCreateCredentials() {
|
||||||
$this->jobList
|
$this->jobList
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
|
|
|
@ -29,6 +29,16 @@ namespace OC\Files\Storage\Wrapper;
|
||||||
class Availability extends Wrapper {
|
class Availability extends Wrapper {
|
||||||
const RECHECK_TTL_SEC = 600; // 10 minutes
|
const RECHECK_TTL_SEC = 600; // 10 minutes
|
||||||
|
|
||||||
|
public static function shouldRecheck($availability) {
|
||||||
|
if (!$availability['available']) {
|
||||||
|
// trigger a recheck if TTL reached
|
||||||
|
if ((time() - $availability['last_checked']) > self::RECHECK_TTL_SEC) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@ -47,12 +57,9 @@ class Availability extends Wrapper {
|
||||||
*/
|
*/
|
||||||
private function isAvailable() {
|
private function isAvailable() {
|
||||||
$availability = $this->getAvailability();
|
$availability = $this->getAvailability();
|
||||||
if (!$availability['available']) {
|
if (self::shouldRecheck($availability)) {
|
||||||
// trigger a recheck if TTL reached
|
|
||||||
if ((time() - $availability['last_checked']) > self::RECHECK_TTL_SEC) {
|
|
||||||
return $this->updateAvailability();
|
return $this->updateAvailability();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return $availability['available'];
|
return $availability['available'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue