summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/App/AppManager.php16
-rw-r--r--lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php8
-rw-r--r--lib/private/Files/Cache/Storage.php5
-rw-r--r--lib/private/Files/Node/File.php2
-rw-r--r--lib/private/Files/Node/Folder.php14
-rw-r--r--lib/private/Files/Node/HookConnector.php20
-rw-r--r--lib/private/Files/Node/Node.php24
-rw-r--r--lib/private/Files/Storage/Wrapper/Availability.php206
-rw-r--r--lib/private/Repair.php2
-rw-r--r--lib/private/Repair/NC16/RemoveCypressFiles.php82
-rw-r--r--lib/private/Server.php2
-rw-r--r--lib/private/Settings/Manager.php4
-rw-r--r--lib/private/legacy/app.php2
13 files changed, 172 insertions, 215 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php
index 322731d677c..19242245600 100644
--- a/lib/private/App/AppManager.php
+++ b/lib/private/App/AppManager.php
@@ -13,6 +13,7 @@
* @author Robin Appelman <robin@icewind.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Vincent Petry <pvince81@owncloud.com>
+ * @author Daniel Rudolf <nextcloud.com@daniel-rudolf.de>
*
* @license AGPL-3.0
*
@@ -404,6 +405,21 @@ class AppManager implements IAppManager {
}
/**
+ * Get the web path for the given app.
+ *
+ * @param string $appId
+ * @return string
+ * @throws AppPathNotFoundException if app path can't be found
+ */
+ public function getAppWebPath(string $appId): string {
+ $appWebPath = \OC_App::getAppWebPath($appId);
+ if($appWebPath === false) {
+ throw new AppPathNotFoundException('Could not find web path for ' . $appId);
+ }
+ return $appWebPath;
+ }
+
+ /**
* Clear the cached list of apps when enabling/disabling an app
*/
public function clearAppsCache() {
diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
index a9d2f6f9a35..3b67661c8b0 100644
--- a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
+++ b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php
@@ -76,4 +76,12 @@ class FunctionBuilder implements IFunctionBuilder {
$alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
return new QueryFunction('COUNT(' . $this->helper->quoteColumnName($count) . ')' . $alias);
}
+
+ public function max($field) {
+ return new QueryFunction('MAX(' . $this->helper->quoteColumnName($field) . ')');
+ }
+
+ public function min($field) {
+ return new QueryFunction('MIN(' . $this->helper->quoteColumnName($field) . ')');
+ }
}
diff --git a/lib/private/Files/Cache/Storage.php b/lib/private/Files/Cache/Storage.php
index 5b37c1f43f8..72aaac11c54 100644
--- a/lib/private/Files/Cache/Storage.php
+++ b/lib/private/Files/Cache/Storage.php
@@ -166,11 +166,12 @@ class Storage {
/**
* @param bool $isAvailable
+ * @param int $delay amount of seconds to delay reconsidering that storage further
*/
- public function setAvailability($isAvailable) {
+ public function setAvailability($isAvailable, int $delay = 0) {
$sql = 'UPDATE `*PREFIX*storages` SET `available` = ?, `last_checked` = ? WHERE `id` = ?';
$available = $isAvailable ? 1 : 0;
- \OC_DB::executeAudited($sql, array($available, time(), $this->storageId));
+ \OC_DB::executeAudited($sql, [$available, time() + $delay, $this->storageId]);
}
/**
diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php
index a3eabbcc446..b504c7a29da 100644
--- a/lib/private/Files/Node/File.php
+++ b/lib/private/Files/Node/File.php
@@ -119,7 +119,7 @@ class File extends Node implements \OCP\Files\File {
$fileInfo = $this->getFileInfo();
$this->view->unlink($this->path);
$nonExisting = new NonExistingFile($this->root, $this->view, $this->path, $fileInfo);
- $this->root->emit('\OC\Files', 'postDelete', array($nonExisting));
+ $this->sendHooks(['postDelete'], [$nonExisting]);
$this->exists = false;
$this->fileInfo = null;
} else {
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php
index 19f04048779..8b2a93ffdc2 100644
--- a/lib/private/Files/Node/Folder.php
+++ b/lib/private/Files/Node/Folder.php
@@ -156,14 +156,12 @@ class Folder extends Node implements \OCP\Files\Folder {
if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) {
$fullPath = $this->getFullPath($path);
$nonExisting = new NonExistingFolder($this->root, $this->view, $fullPath);
- $this->root->emit('\OC\Files', 'preWrite', array($nonExisting));
- $this->root->emit('\OC\Files', 'preCreate', array($nonExisting));
+ $this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]);
if(!$this->view->mkdir($fullPath)) {
throw new NotPermittedException('Could not create folder');
}
$node = new Folder($this->root, $this->view, $fullPath);
- $this->root->emit('\OC\Files', 'postWrite', array($node));
- $this->root->emit('\OC\Files', 'postCreate', array($node));
+ $this->sendHooks(['postWrite', 'postCreate'], [$node]);
return $node;
} else {
throw new NotPermittedException('No create permission for folder');
@@ -179,14 +177,12 @@ class Folder extends Node implements \OCP\Files\Folder {
if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) {
$fullPath = $this->getFullPath($path);
$nonExisting = new NonExistingFile($this->root, $this->view, $fullPath);
- $this->root->emit('\OC\Files', 'preWrite', array($nonExisting));
- $this->root->emit('\OC\Files', 'preCreate', array($nonExisting));
+ $this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]);
if (!$this->view->touch($fullPath)) {
throw new NotPermittedException('Could not create path');
}
$node = new File($this->root, $this->view, $fullPath);
- $this->root->emit('\OC\Files', 'postWrite', array($node));
- $this->root->emit('\OC\Files', 'postCreate', array($node));
+ $this->sendHooks(['postWrite', 'postCreate'], [$node]);
return $node;
}
throw new NotPermittedException('No create permission for path');
@@ -341,7 +337,7 @@ class Folder extends Node implements \OCP\Files\Folder {
$fileInfo = $this->getFileInfo();
$this->view->rmdir($this->path);
$nonExisting = new NonExistingFolder($this->root, $this->view, $this->path, $fileInfo);
- $this->root->emit('\OC\Files', 'postDelete', array($nonExisting));
+ $this->sendHooks(['postDelete'], [$nonExisting]);
$this->exists = false;
} else {
throw new NotPermittedException('No delete permission for path');
diff --git a/lib/private/Files/Node/HookConnector.php b/lib/private/Files/Node/HookConnector.php
index f5adcde4a00..4783a71b07b 100644
--- a/lib/private/Files/Node/HookConnector.php
+++ b/lib/private/Files/Node/HookConnector.php
@@ -26,6 +26,8 @@ use OCP\Files\FileInfo;
use OC\Files\Filesystem;
use OC\Files\View;
use OCP\Util;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\GenericEvent;
class HookConnector {
/**
@@ -42,6 +44,8 @@ class HookConnector {
* @var FileInfo[]
*/
private $deleteMetaCache = [];
+ /** @var EventDispatcherInterface */
+ private $dispatcher;
/**
* HookConnector constructor.
@@ -49,9 +53,10 @@ class HookConnector {
* @param Root $root
* @param View $view
*/
- public function __construct(Root $root, View $view) {
+ public function __construct(Root $root, View $view, EventDispatcherInterface $dispatcher) {
$this->root = $root;
$this->view = $view;
+ $this->dispatcher = $dispatcher;
}
public function viewToNode() {
@@ -79,72 +84,85 @@ class HookConnector {
public function write($arguments) {
$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'preWrite', [$node]);
+ $this->dispatcher->dispatch('\OCP\Files::preWrite', new GenericEvent($node));
}
public function postWrite($arguments) {
$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'postWrite', [$node]);
+ $this->dispatcher->dispatch('\OCP\Files::postWrite', new GenericEvent($node));
}
public function create($arguments) {
$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'preCreate', [$node]);
+ $this->dispatcher->dispatch('\OCP\Files::preCreate', new GenericEvent($node));
}
public function postCreate($arguments) {
$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'postCreate', [$node]);
+ $this->dispatcher->dispatch('\OCP\Files::postCreate', new GenericEvent($node));
}
public function delete($arguments) {
$node = $this->getNodeForPath($arguments['path']);
$this->deleteMetaCache[$node->getPath()] = $node->getFileInfo();
$this->root->emit('\OC\Files', 'preDelete', [$node]);
+ $this->dispatcher->dispatch('\OCP\Files::preDelete', new GenericEvent($node));
}
public function postDelete($arguments) {
$node = $this->getNodeForPath($arguments['path']);
unset($this->deleteMetaCache[$node->getPath()]);
$this->root->emit('\OC\Files', 'postDelete', [$node]);
+ $this->dispatcher->dispatch('\OCP\Files::postDelete', new GenericEvent($node));
}
public function touch($arguments) {
$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'preTouch', [$node]);
+ $this->dispatcher->dispatch('\OCP\Files::preTouch', new GenericEvent($node));
}
public function postTouch($arguments) {
$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'postTouch', [$node]);
+ $this->dispatcher->dispatch('\OCP\Files::postTouch', new GenericEvent($node));
}
public function rename($arguments) {
$source = $this->getNodeForPath($arguments['oldpath']);
$target = $this->getNodeForPath($arguments['newpath']);
$this->root->emit('\OC\Files', 'preRename', [$source, $target]);
+ $this->dispatcher->dispatch('\OCP\Files::preRename', new GenericEvent([$source, $target]));
}
public function postRename($arguments) {
$source = $this->getNodeForPath($arguments['oldpath']);
$target = $this->getNodeForPath($arguments['newpath']);
$this->root->emit('\OC\Files', 'postRename', [$source, $target]);
+ $this->dispatcher->dispatch('\OCP\Files::postRename', new GenericEvent([$source, $target]));
}
public function copy($arguments) {
$source = $this->getNodeForPath($arguments['oldpath']);
$target = $this->getNodeForPath($arguments['newpath']);
$this->root->emit('\OC\Files', 'preCopy', [$source, $target]);
+ $this->dispatcher->dispatch('\OCP\Files::preCopy', new GenericEvent([$source, $target]));
}
public function postCopy($arguments) {
$source = $this->getNodeForPath($arguments['oldpath']);
$target = $this->getNodeForPath($arguments['newpath']);
$this->root->emit('\OC\Files', 'postCopy', [$source, $target]);
+ $this->dispatcher->dispatch('\OCP\Files::postCopy', new GenericEvent([$source, $target]));
}
public function read($arguments) {
$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'read', [$node]);
+ $this->dispatcher->dispatch('\OCP\Files::read', new GenericEvent([$node]));
}
private function getNodeForPath($path) {
diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php
index dc025b79575..c440dd4a8f1 100644
--- a/lib/private/Files/Node/Node.php
+++ b/lib/private/Files/Node/Node.php
@@ -33,6 +33,7 @@ use OCP\Files\FileInfo;
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
+use Symfony\Component\EventDispatcher\GenericEvent;
// FIXME: this class really should be abstract
class Node implements \OCP\Files\Node {
@@ -104,9 +105,12 @@ class Node implements \OCP\Files\Node {
/**
* @param string[] $hooks
*/
- protected function sendHooks($hooks) {
+ protected function sendHooks($hooks, array $args = null) {
+ $args = !empty($args) ? $args : [$this];
+ $dispatcher = \OC::$server->getEventDispatcher();
foreach ($hooks as $hook) {
- $this->root->emit('\OC\Files', $hook, array($this));
+ $this->root->emit('\OC\Files', $hook, $args);
+ $dispatcher->dispatch('\OCP\Files::' . $hook, new GenericEvent($args));
}
}
@@ -394,14 +398,14 @@ class Node implements \OCP\Files\Node {
$parent = $this->root->get(dirname($targetPath));
if ($parent instanceof Folder and $this->isValidPath($targetPath) and $parent->isCreatable()) {
$nonExisting = $this->createNonExistingNode($targetPath);
- $this->root->emit('\OC\Files', 'preCopy', [$this, $nonExisting]);
- $this->root->emit('\OC\Files', 'preWrite', [$nonExisting]);
+ $this->sendHooks(['preCopy'], [$this, $nonExisting]);
+ $this->sendHooks(['preWrite'], [$nonExisting]);
if (!$this->view->copy($this->path, $targetPath)) {
throw new NotPermittedException('Could not copy ' . $this->path . ' to ' . $targetPath);
}
$targetNode = $this->root->get($targetPath);
- $this->root->emit('\OC\Files', 'postCopy', [$this, $targetNode]);
- $this->root->emit('\OC\Files', 'postWrite', [$targetNode]);
+ $this->sendHooks(['postCopy'], [$this, $targetNode]);
+ $this->sendHooks(['postWrite'], [$targetNode]);
return $targetNode;
} else {
throw new NotPermittedException('No permission to copy to path ' . $targetPath);
@@ -425,14 +429,14 @@ class Node implements \OCP\Files\Node {
)
) {
$nonExisting = $this->createNonExistingNode($targetPath);
- $this->root->emit('\OC\Files', 'preRename', [$this, $nonExisting]);
- $this->root->emit('\OC\Files', 'preWrite', [$nonExisting]);
+ $this->sendHooks(['preRename'], [$this, $nonExisting]);
+ $this->sendHooks(['preWrite'], [$nonExisting]);
if (!$this->view->rename($this->path, $targetPath)) {
throw new NotPermittedException('Could not move ' . $this->path . ' to ' . $targetPath);
}
$targetNode = $this->root->get($targetPath);
- $this->root->emit('\OC\Files', 'postRename', [$this, $targetNode]);
- $this->root->emit('\OC\Files', 'postWrite', [$targetNode]);
+ $this->sendHooks(['postRename'], [$this, $targetNode]);
+ $this->sendHooks(['postWrite'], [$targetNode]);
$this->path = $targetPath;
return $targetNode;
} else {
diff --git a/lib/private/Files/Storage/Wrapper/Availability.php b/lib/private/Files/Storage/Wrapper/Availability.php
index 5b957ae036b..77a23d26fb7 100644
--- a/lib/private/Files/Storage/Wrapper/Availability.php
+++ b/lib/private/Files/Storage/Wrapper/Availability.php
@@ -24,6 +24,9 @@
namespace OC\Files\Storage\Wrapper;
use OCP\Files\Storage\IStorage;
+use OCP\Files\StorageAuthException;
+use OCP\Files\StorageNotAvailableException;
+use OCP\IConfig;
/**
* Availability checker for storages
@@ -33,6 +36,14 @@ use OCP\Files\Storage\IStorage;
class Availability extends Wrapper {
const RECHECK_TTL_SEC = 600; // 10 minutes
+ /** @var IConfig */
+ protected $config;
+
+ public function __construct($parameters) {
+ $this->config = $parameters['config'] ?? \OC::$server->getConfig();
+ parent::__construct($parameters);
+ }
+
public static function shouldRecheck($availability) {
if (!$availability['available']) {
// trigger a recheck if TTL reached
@@ -72,11 +83,11 @@ class Availability extends Wrapper {
}
/**
- * @throws \OCP\Files\StorageNotAvailableException
+ * @throws StorageNotAvailableException
*/
private function checkAvailability() {
if (!$this->isAvailable()) {
- throw new \OCP\Files\StorageNotAvailableException();
+ throw new StorageNotAvailableException();
}
}
@@ -85,9 +96,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::mkdir($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -96,9 +106,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::rmdir($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -107,9 +116,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::opendir($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -118,9 +126,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::is_dir($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -129,9 +136,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::is_file($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -140,9 +146,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::stat($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -151,9 +156,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::filetype($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -162,9 +166,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::filesize($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -173,9 +176,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::isCreatable($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -184,9 +186,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::isReadable($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -195,9 +196,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::isUpdatable($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -206,9 +206,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::isDeletable($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -217,9 +216,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::isSharable($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -228,9 +226,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::getPermissions($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -242,9 +239,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::file_exists($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -253,9 +249,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::filemtime($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -264,9 +259,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::file_get_contents($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -275,9 +269,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::file_put_contents($path, $data);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -286,9 +279,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::unlink($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -297,9 +289,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::rename($path1, $path2);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -308,9 +299,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::copy($path1, $path2);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -319,9 +309,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::fopen($path, $mode);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -330,9 +319,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::getMimeType($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -341,9 +329,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::hash($type, $path, $raw);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -352,9 +339,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::free_space($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -363,9 +349,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::search($query);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -374,9 +359,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::touch($path, $mtime);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -385,9 +369,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::getLocalFile($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -396,9 +379,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::hasUpdated($path, $time);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -406,9 +388,8 @@ class Availability extends Wrapper {
public function getOwner($path) {
try {
return parent::getOwner($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -417,9 +398,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::getETag($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -428,9 +408,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::getDirectDownload($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -439,9 +418,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -450,9 +428,8 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
@@ -461,9 +438,24 @@ class Availability extends Wrapper {
$this->checkAvailability();
try {
return parent::getMetaData($path);
- } catch (\OCP\Files\StorageNotAvailableException $e) {
- $this->setAvailability(false);
- throw $e;
+ } catch (StorageNotAvailableException $e) {
+ $this->setUnavailable($e);
}
}
+
+ /**
+ * @throws StorageNotAvailableException
+ */
+ protected function setUnavailable(StorageNotAvailableException $e) {
+ $delay = self::RECHECK_TTL_SEC;
+ if($e instanceof StorageAuthException) {
+ $delay = max(
+ // 30min
+ $this->config->getSystemValueInt('external_storage.auth_availability_delay', 1800),
+ self::RECHECK_TTL_SEC
+ );
+ }
+ $this->getStorageCache()->setAvailability(false, $delay);
+ throw $e;
+ }
}
diff --git a/lib/private/Repair.php b/lib/private/Repair.php
index 70a15cb0442..2b6080ca985 100644
--- a/lib/private/Repair.php
+++ b/lib/private/Repair.php
@@ -43,7 +43,6 @@ use OC\Repair\NC14\AddPreviewBackgroundCleanupJob;
use OC\Repair\NC16\AddClenupLoginFlowV2BackgroundJob;
use OC\Repair\NC16\CleanupCardDAVPhotoCache;
use OC\Repair\NC16\ClearCollectionsAccessCache;
-use OC\Repair\NC16\RemoveCypressFiles;
use OC\Repair\NC17\SetEnterpriseLogo;
use OC\Repair\NC17\SwitchUpdateChannel;
use OC\Repair\OldGroupMembershipShares;
@@ -153,7 +152,6 @@ class Repair implements IOutput {
new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OC::$server->query(IManager::class)),
- \OC::$server->query(RemoveCypressFiles::class),
\OC::$server->query(SwitchUpdateChannel::class),
\OC::$server->query(SetEnterpriseLogo::class),
];
diff --git a/lib/private/Repair/NC16/RemoveCypressFiles.php b/lib/private/Repair/NC16/RemoveCypressFiles.php
deleted file mode 100644
index 4b6108d0232..00000000000
--- a/lib/private/Repair/NC16/RemoveCypressFiles.php
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-declare(strict_types=1);
-/**
- * @copyright Copyright (c) 2019, Morris Jobke <hey@morrisjobke.de>
- *
- * @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\NC16;
-
-use OC\IntegrityCheck\Checker;
-use OCP\Migration\IOutput;
-use OCP\Migration\IRepairStep;
-
-/**
- * Class CleanupCypressFiles
- *
- * This repair step removes "cypress" files and folder created by viewer app in 16.0.1
- *
- * See https://github.com/nextcloud/server/issues/16229 for more details.
- *
- * @deprecated - can be removed in 18 because this is the first version where no migration from 16 can happen
- */
-class RemoveCypressFiles implements IRepairStep {
-
- /** @var Checker $checker */
- private $checker;
-
- private $pathToViewerApp = __DIR__ . '/../../../../apps/viewer';
-
- public function getName(): string {
- return 'Cleanup cypress files from viewer app';
- }
-
- public function __construct(Checker $checker) {
- $this->checker = $checker;
- }
-
- public function run(IOutput $output): void {
- $file = $this->pathToViewerApp . '/cypress.json';
- if (file_exists($file)) {
- unlink($file);
- }
-
- $dir = $this->pathToViewerApp . '/cypress';
- if (is_dir($dir)) {
- $files = new \RecursiveIteratorIterator(
- new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS),
- \RecursiveIteratorIterator::CHILD_FIRST
- );
-
- foreach ($files as $fileInfo) {
- /** @var \SplFileInfo $fileInfo */
- if ($fileInfo->isLink()) {
- unlink($fileInfo->getPathname());
- } else if ($fileInfo->isDir()) {
- rmdir($fileInfo->getRealPath());
- } else {
- unlink($fileInfo->getRealPath());
- }
- }
- rmdir($dir);
- }
-
- // re-run the instance verification
- $this->checker->runInstanceVerification();
- }
-}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index bce4f0feaef..433ee044fa4 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -298,7 +298,7 @@ class Server extends ServerContainer implements IServerContainer {
$this->getLogger(),
$this->getUserManager()
);
- $connector = new HookConnector($root, $view);
+ $connector = new HookConnector($root, $view, $c->getEventDispatcher());
$connector->viewToNode();
$previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php
index 7e3edfa9df0..1a9e8261ee8 100644
--- a/lib/private/Settings/Manager.php
+++ b/lib/private/Settings/Manager.php
@@ -298,6 +298,10 @@ class Manager implements IManager {
/** @var ISettings $form */
$form = $this->container->query(Personal\Security::class);
$forms[$form->getPriority()] = [$form];
+
+ /** @var ISettings $form */
+ $form = $this->container->query(Personal\Security\Authtokens::class);
+ $forms[$form->getPriority()] = [$form];
}
if ($section === 'additional') {
/** @var ISettings $form */
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index 58b617aae45..9e47f9064d9 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -485,6 +485,7 @@ class OC_App {
*
* @param string $appId
* @return string|false
+ * @deprecated 11.0.0 use \OC::$server->getAppManager()->getAppPath()
*/
public static function getAppPath(string $appId) {
if ($appId === null || trim($appId) === '') {
@@ -503,6 +504,7 @@ class OC_App {
*
* @param string $appId
* @return string|false
+ * @deprecated 18.0.0 use \OC::$server->getAppManager()->getAppWebPath()
*/
public static function getAppWebPath(string $appId) {
if (($dir = self::findAppInDirectories($appId)) != false) {