improved logging of objectore errors
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
0d7d00d681
commit
a277101133
|
@ -46,6 +46,8 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
|
||||||
|
|
||||||
private $objectPrefix = 'urn:oid:';
|
private $objectPrefix = 'urn:oid:';
|
||||||
|
|
||||||
|
private $logger;
|
||||||
|
|
||||||
public function __construct($params) {
|
public function __construct($params) {
|
||||||
if (isset($params['objectstore']) && $params['objectstore'] instanceof IObjectStore) {
|
if (isset($params['objectstore']) && $params['objectstore'] instanceof IObjectStore) {
|
||||||
$this->objectStore = $params['objectstore'];
|
$this->objectStore = $params['objectstore'];
|
||||||
|
@ -64,6 +66,8 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
|
||||||
if (!$this->is_dir('/')) {
|
if (!$this->is_dir('/')) {
|
||||||
$this->mkdir('/');
|
$this->mkdir('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->logger = \OC::$server->getLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mkdir($path) {
|
public function mkdir($path) {
|
||||||
|
@ -185,7 +189,10 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
|
||||||
$this->objectStore->deleteObject($this->getURN($stat['fileid']));
|
$this->objectStore->deleteObject($this->getURN($stat['fileid']));
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
if ($ex->getCode() !== 404) {
|
if ($ex->getCode() !== 404) {
|
||||||
\OCP\Util::writeLog('objectstore', 'Could not delete object: ' . $ex->getMessage(), \OCP\Util::ERROR);
|
$this->logger->logException($ex, [
|
||||||
|
'app' => 'objectstore',
|
||||||
|
'message' => 'Could not delete object ' . $this->getURN($stat['fileid']) . ' for ' . $path,
|
||||||
|
]);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
//removing from cache is ok as it does not exist in the objectstore anyway
|
//removing from cache is ok as it does not exist in the objectstore anyway
|
||||||
|
@ -234,7 +241,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
|
||||||
|
|
||||||
return IteratorDirectory::wrap($files);
|
return IteratorDirectory::wrap($files);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\OCP\Util::writeLog('objectstore', $e->getMessage(), \OCP\Util::ERROR);
|
$this->logger->logException($e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +270,10 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
|
||||||
try {
|
try {
|
||||||
return $this->objectStore->readObject($this->getURN($stat['fileid']));
|
return $this->objectStore->readObject($this->getURN($stat['fileid']));
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
\OCP\Util::writeLog('objectstore', 'Could not get object: ' . $ex->getMessage(), \OCP\Util::ERROR);
|
$this->logger->logException($ex, [
|
||||||
|
'app' => 'objectstore',
|
||||||
|
'message' => 'Count not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path,
|
||||||
|
]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -357,7 +367,10 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
|
||||||
$this->objectStore->writeObject($this->getURN($fileId), fopen('php://memory', 'r'));
|
$this->objectStore->writeObject($this->getURN($fileId), fopen('php://memory', 'r'));
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
$this->getCache()->remove($path);
|
$this->getCache()->remove($path);
|
||||||
\OCP\Util::writeLog('objectstore', 'Could not create object: ' . $ex->getMessage(), \OCP\Util::ERROR);
|
$this->logger->logException($ex, [
|
||||||
|
'app' => 'objectstore',
|
||||||
|
'message' => 'Could not create object ' . $this->getURN($fileId) . ' for ' . $path,
|
||||||
|
]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,7 +399,10 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
|
||||||
$this->objectStore->writeObject($this->getURN($fileId), fopen($tmpFile, 'r'));
|
$this->objectStore->writeObject($this->getURN($fileId), fopen($tmpFile, 'r'));
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
$this->getCache()->remove($path);
|
$this->getCache()->remove($path);
|
||||||
\OCP\Util::writeLog('objectstore', 'Could not create object: ' . $ex->getMessage(), \OCP\Util::ERROR);
|
$this->logger->logException($ex, [
|
||||||
|
'app' => 'objectstore',
|
||||||
|
'message' => 'Could not create object ' . $this->getURN($fileId) . ' for ' . $path,
|
||||||
|
]);
|
||||||
throw $ex; // make this bubble up
|
throw $ex; // make this bubble up
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue