9f6dcb9d3e
- VObject fixes for Sabre\VObject 3.3 - Remove VObject property workarounds - Added prefetching for tags in sabre tags plugin - Moved oc_properties logic to separate PropertyStorage backend (WIP) - Fixed Sabre connector namespaces - Improved files plugin to handle props on-demand - Moved allowed props from server class to files plugin - Fixed tags caching for files that are known to have no tags (less queries) - Added/fixed unit tests for Sabre FilesPlugin, TagsPlugin - Replace OC\Connector\Sabre\Request with direct call to httpRequest->setUrl() - Fix exception detection in DAV client when using Sabre\DAV\Client - Added setETag() on Node instead of using the static FileSystem - Also preload tags/props when depth is infinity
49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
namespace OC\Connector\Sabre;
|
|
|
|
class MaintenancePlugin extends \Sabre\DAV\ServerPlugin
|
|
{
|
|
|
|
/**
|
|
* Reference to main server object
|
|
*
|
|
* @var \Sabre\DAV\Server
|
|
*/
|
|
private $server;
|
|
|
|
/**
|
|
* This initializes the plugin.
|
|
*
|
|
* This function is called by \Sabre\DAV\Server, after
|
|
* addPlugin is called.
|
|
*
|
|
* This method should set up the required event subscriptions.
|
|
*
|
|
* @param \Sabre\DAV\Server $server
|
|
* @return void
|
|
*/
|
|
public function initialize(\Sabre\DAV\Server $server) {
|
|
|
|
$this->server = $server;
|
|
$this->server->on('beforeMethod', array($this, 'checkMaintenanceMode'), 10);
|
|
}
|
|
|
|
/**
|
|
* This method is called before any HTTP method and returns http status code 503
|
|
* in case the system is in maintenance mode.
|
|
*
|
|
* @throws \Sabre\DAV\Exception\ServiceUnavailable
|
|
* @internal param string $method
|
|
* @return bool
|
|
*/
|
|
public function checkMaintenanceMode() {
|
|
if (\OC_Config::getValue('maintenance', false)) {
|
|
throw new \Sabre\DAV\Exception\ServiceUnavailable();
|
|
}
|
|
if (\OC::checkUpgrade(false)) {
|
|
throw new \Sabre\DAV\Exception\ServiceUnavailable('Upgrade needed');
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|