Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,10 @@ public function getSettingsFile(string $type, string $token, string $category, s
]
);
} catch (NotFoundException $e) {
$this->logger->info('Settings file not found', ['type' => $type, 'category' => $category, 'name' => $name, 'exception' => $e]);
return new DataDisplayResponse('File not found.', 404);
} catch (\Exception $e) {
$this->logger->error('Error fetching settings file', ['exception' => $e]);
return new DataDisplayResponse('Something went wrong', 500);
}
}
Expand Down
79 changes: 79 additions & 0 deletions lib/TemplateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,51 @@ public function setUserId(?string $userId): void {
$this->userId = $userId;
}

private function debugStorage($file) {
$storage = $file->getStorage();

while ($storage) {
$class = get_class($storage);
$this->logger->warning(
'DEBUG: storage unwrap {fullPath} ({internalPath}) {className} with permissions {permissions}, double-check is it readable: {isReadable}',
[
'app' => Application::APPNAME,
'fullPath' => $file->getPath(),
'internalPath' => $file->getInternalPath(),
'permissions' => $storage->getPermissions($file->getInternalPath()),
'isReadable' => $storage->isReadable($file->getInternalPath()),
'className' => $class,
]
);
if ($storage instanceof \OC\Files\Storage\Wrapper\Wrapper) {
$storage = $storage->getWrapperStorage();
} else {
$storage = null;
}
}

$cache = $file->getStorage()->getCache();

while ($cache) {
$class = get_class($cache);
$this->logger->warning(
'DEBUG: cache unwrap {fullPath} ({internalPath}) {className} with permissions {permissions}',
[
'app' => Application::APPNAME,
'fullPath' => $file->getPath(),
'internalPath' => $file->getInternalPath(),
'permissions' => $cache->get($file->getInternalPath())->getPermissions(),
'className' => $class,
]
);
if ($cache instanceof \OC\Files\Cache\Wrapper\CacheWrapper) {
$cache = $cache->getCache();
} else {
$cache = null;
}
}
}

/**
* Get template ISimpleFile|Node
*
Expand All @@ -119,6 +164,18 @@ public function get(int $fileId) {

foreach ($files as $file) {
if ($file->getId() === $fileId) {
$this->logger->warning(
'DEBUG: found template in empty_templates dir: {fullPath} ({internalPath}) with permissions {permissions}, double-check is it readable: {isReadable}',
[
'app' => Application::APPNAME,
'fullPath' => $file->getPath(),
'internalPath' => $file->getInternalPath(),
'permissions' => $file->getPermissions(),
'isReadable' => $file->isReadable(),
]
);
$this->debugStorage($file);

return $file;
}
}
Expand All @@ -132,6 +189,17 @@ public function get(int $fileId) {

foreach ($files as $file) {
if ($file->getId() === $fileId) {
$this->logger->warning(
'DEBUG: found template in system templates dir: {fullPath} ({internalPath}) with permissions {permissions}, double-check is it readable: {isReadable}',
[
'app' => Application::APPNAME,
'fullPath' => $file->getPath(),
'internalPath' => $file->getInternalPath(),
'permissions' => $file->getPermissions(),
'isReadable' => $file->isReadable(),
]
);
$this->debugStorage($file);
return $file;
}
}
Expand All @@ -140,6 +208,17 @@ public function get(int $fileId) {
// finally get the template file
$file = $templateDir->getFirstNodeById($fileId);
if ($file !== null) {
$this->logger->warning(
'DEBUG: found template in user templates dir: {fullPath} ({internalPath}) with permissions {permissions}, double-check is it readable: {isReadable}',
[
'app' => Application::APPNAME,
'fullPath' => $file->getPath(),
'internalPath' => $file->getInternalPath(),
'permissions' => $file->getPermissions(),
'isReadable' => $file->isReadable(),
]
);
$this->debugStorage($file);
return $file;
}

Expand Down
Loading