|
|
|
|
|
|
|
|
namespace OC\Files\Storage\Wrapper; |
|
|
namespace OC\Files\Storage\Wrapper; |
|
|
|
|
|
|
|
|
use OCP\Files\Storage\IStorage; |
|
|
use OCP\Files\Storage\IStorage; |
|
|
|
|
|
use OCP\Files\StorageAuthException; |
|
|
|
|
|
use OCP\Files\StorageNotAvailableException; |
|
|
|
|
|
use OCP\IConfig; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Availability checker for storages |
|
|
* Availability checker for storages |
|
|
|
|
|
|
|
|
class Availability extends Wrapper { |
|
|
class Availability extends Wrapper { |
|
|
const RECHECK_TTL_SEC = 600; // 10 minutes |
|
|
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) { |
|
|
public static function shouldRecheck($availability) { |
|
|
if (!$availability['available']) { |
|
|
if (!$availability['available']) { |
|
|
// trigger a recheck if TTL reached |
|
|
// trigger a recheck if TTL reached |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @throws \OCP\Files\StorageNotAvailableException |
|
|
|
|
|
|
|
|
* @throws StorageNotAvailableException |
|
|
*/ |
|
|
*/ |
|
|
private function checkAvailability() { |
|
|
private function checkAvailability() { |
|
|
if (!$this->isAvailable()) { |
|
|
if (!$this->isAvailable()) { |
|
|
throw new \OCP\Files\StorageNotAvailableException(); |
|
|
|
|
|
|
|
|
throw new StorageNotAvailableException(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::mkdir($path); |
|
|
return parent::mkdir($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::rmdir($path); |
|
|
return parent::rmdir($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::opendir($path); |
|
|
return parent::opendir($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::is_dir($path); |
|
|
return parent::is_dir($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::is_file($path); |
|
|
return parent::is_file($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::stat($path); |
|
|
return parent::stat($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::filetype($path); |
|
|
return parent::filetype($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::filesize($path); |
|
|
return parent::filesize($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::isCreatable($path); |
|
|
return parent::isCreatable($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::isReadable($path); |
|
|
return parent::isReadable($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::isUpdatable($path); |
|
|
return parent::isUpdatable($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::isDeletable($path); |
|
|
return parent::isDeletable($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::isSharable($path); |
|
|
return parent::isSharable($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::getPermissions($path); |
|
|
return parent::getPermissions($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::file_exists($path); |
|
|
return parent::file_exists($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::filemtime($path); |
|
|
return parent::filemtime($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::file_get_contents($path); |
|
|
return parent::file_get_contents($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::file_put_contents($path, $data); |
|
|
return parent::file_put_contents($path, $data); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::unlink($path); |
|
|
return parent::unlink($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::rename($path1, $path2); |
|
|
return parent::rename($path1, $path2); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::copy($path1, $path2); |
|
|
return parent::copy($path1, $path2); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::fopen($path, $mode); |
|
|
return parent::fopen($path, $mode); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::getMimeType($path); |
|
|
return parent::getMimeType($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::hash($type, $path, $raw); |
|
|
return parent::hash($type, $path, $raw); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::free_space($path); |
|
|
return parent::free_space($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::search($query); |
|
|
return parent::search($query); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::touch($path, $mtime); |
|
|
return parent::touch($path, $mtime); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::getLocalFile($path); |
|
|
return parent::getLocalFile($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::hasUpdated($path, $time); |
|
|
return parent::hasUpdated($path, $time); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getOwner($path) { |
|
|
public function getOwner($path) { |
|
|
try { |
|
|
try { |
|
|
return parent::getOwner($path); |
|
|
return parent::getOwner($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::getETag($path); |
|
|
return parent::getETag($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::getDirectDownload($path); |
|
|
return parent::getDirectDownload($path); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
|
return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
|
return parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
|
} catch (\OCP\Files\StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setAvailability(false); |
|
|
|
|
|
throw $e; |
|
|
|
|
|
|
|
|
} catch (StorageNotAvailableException $e) { |
|
|
|
|
|
$this->setUnavailable($e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->checkAvailability(); |
|
|
$this->checkAvailability(); |
|
|
try { |
|
|
try { |
|
|
return parent::getMetaData($path); |
|
|
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; |
|
|
|
|
|
} |
|
|
} |
|
|
} |