refactor: forcePermissions typing

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/888/head
Varun Patil 2023-10-22 13:47:12 -07:00
parent b3f8387a95
commit c9e87c4cf6
2 changed files with 6 additions and 19 deletions

View File

@ -196,7 +196,7 @@ class ImageController extends GenericApiController
$info['etag'] = $file->getEtag();
// Inject permissions and convert to string
$info['permissions'] = \OCA\Memories\Util::permissionsToStr($file->getPermissions());
$info['permissions'] = Util::permissionsToStr($file->getPermissions());
// Inject other file parameters that are cheap to get now
$info['mimetype'] = $file->getMimeType();

View File

@ -186,23 +186,6 @@ class Util
return true;
}
/**
* Force a fileinfo value on a node.
* This is a hack to avoid subclassing everything.
*
* @param Node $node File to patch
* @param string $key Key to set
* @param mixed $value Value to set
*/
public static function forceFileInfo(Node &$node, string $key, mixed $value): void
{
/** @var \OC\Files\Node\Node */
$node = $node;
/** @psalm-suppress UndefinedInterfaceMethod */
$node->getFileInfo()[$key] = $value;
}
/**
* Force permissions on a node.
*
@ -211,7 +194,11 @@ class Util
*/
public static function forcePermissions(Node &$node, int $permissions): void
{
self::forceFileInfo($node, 'permissions', $permissions);
/** @var \OC\Files\Node\Node $node */
$fileInfo = $node->getFileInfo();
/** @var \OC\Files\FileInfo $fileInfo */
$fileInfo['permissions'] = $permissions;
}
/**